Changeset 7798 for trunk/src/kernel32


Ignore:
Timestamp:
Feb 3, 2002, 10:06:40 PM (24 years ago)
Author:
sandervl
Message:

Ported GetTempPathA/W from Wine

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/Fileio.cpp

    r7722 r7798  
    1 /* $Id: Fileio.cpp,v 1.63 2002-01-02 18:37:51 sandervl Exp $ */
     1/* $Id: Fileio.cpp,v 1.64 2002-02-03 21:06:40 sandervl Exp $ */
    22
    33/*
     
    725725  FreeAsciiString(asciipath);
    726726  free(asciitemp);
    727   return(rc);
    728 }
    729 //******************************************************************************
    730 //******************************************************************************
    731 ODINFUNCTION2(UINT, GetTempPathA,
    732               UINT, arg1,
    733               LPSTR, arg2)
    734 {
    735   return O32_GetTempPath(arg1, arg2);
    736 }
    737 //******************************************************************************
    738 //******************************************************************************
    739 ODINFUNCTION2(UINT, GetTempPathW,
    740               UINT, nBufferLength,
    741               LPWSTR, lpBuffer)
    742 {
    743   char *asciibuffer = (char *)malloc(nBufferLength+1);
    744   DWORD rc;
    745 
    746   rc = O32_GetTempPath(nBufferLength, asciibuffer);
    747   if(rc)      AsciiToUnicode(asciibuffer, lpBuffer);
    748   free(asciibuffer);
    749727  return(rc);
    750728}
  • trunk/src/kernel32/directory.cpp

    r7342 r7798  
    1 /* $Id: directory.cpp,v 1.42 2001-11-14 18:38:45 sandervl Exp $ */
     1/* $Id: directory.cpp,v 1.43 2002-02-03 21:06:40 sandervl Exp $ */
    22
    33/*
     
    754754    return ret;
    755755}
     756//******************************************************************************
     757//******************************************************************************
     758ODINFUNCTION2(UINT, GetTempPathA,
     759              UINT, count, LPSTR, path)
     760{
     761    UINT ret;
     762    if (!(ret = GetEnvironmentVariableA( "TMP", path, count )))
     763        if (!(ret = GetEnvironmentVariableA( "TEMP", path, count )))
     764            if (!(ret = GetCurrentDirectoryA( count, path )))
     765                return 0;
     766    if (count && (ret < count - 1) && (path[ret-1] != '\\'))
     767    {
     768        path[ret++] = '\\';
     769        path[ret]   = '\0';
     770    }
     771    return ret;
     772}
     773//******************************************************************************
     774//******************************************************************************
     775ODINFUNCTION2(UINT, GetTempPathW,
     776              UINT, count, LPWSTR, path)
     777{
     778    static const WCHAR tmp[]  = { 'T', 'M', 'P', 0 };
     779    static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 };
     780    UINT ret;
     781    if (!(ret = GetEnvironmentVariableW( tmp, path, count )))
     782        if (!(ret = GetEnvironmentVariableW( temp, path, count )))
     783            if (!(ret = GetCurrentDirectoryW( count, path )))
     784                return 0;
     785    if (count && (ret < count - 1) && (path[ret-1] != '\\'))
     786    {
     787        path[ret++] = '\\';
     788        path[ret]   = '\0';
     789    }
     790    return ret;
     791}
     792//******************************************************************************
     793//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.