Fix GetCurrentDirectoryA and W to return the needed space for the CWD,

if the buffer size is not large enough.
This commit is contained in:
Peter Ganten 1999-12-05 23:51:56 +00:00 committed by Alexandre Julliard
parent f92a777007
commit ea5941ba26
1 changed files with 13 additions and 8 deletions

View File

@ -286,7 +286,7 @@ int DRIVE_SetCurrentDrive( int drive )
/***********************************************************************
* DRIVE_FindDriveRoot
*
* Find a drive for which the root matches the begginning of the given path.
* Find a drive for which the root matches the beginning of the given path.
* This can be used to translate a Unix path into a drive + DOS path.
* Return value is the drive, or -1 on error. On success, path is modified
* to point to the beginning of the DOS path.
@ -686,7 +686,7 @@ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size,
return 1;
}
/*
/***********************************************************************
* DRIVE_GetCurrentDirectory
* Returns "X:\\path\\etc\\".
*
@ -1033,13 +1033,18 @@ UINT WINAPI GetCurrentDirectoryA( UINT buflen, LPSTR buf )
{
UINT ret;
char longname[MAX_PATHNAME_LEN];
ret = DRIVE_GetCurrentDirectory(buflen, buf);
GetLongPathNameA(buf, longname, buflen);
lstrcpyA(buf, longname);
char shortname[MAX_PATHNAME_LEN];
ret = DRIVE_GetCurrentDirectory(MAX_PATHNAME_LEN, shortname);
if ( ret > MAX_PATHNAME_LEN ) {
ERR_(file)("pathnamelength (%d) > MAX_PATHNAME_LEN!\n", ret );
return ret;
}
GetLongPathNameA(shortname, longname, MAX_PATHNAME_LEN);
ret = lstrlenA( longname ) + 1;
if (ret > buflen) return ret;
lstrcpyA(buf, longname);
return ret - 1;
}
/***********************************************************************
* GetCurrentDirectory32W (KERNEL32.197)
@ -1048,7 +1053,7 @@ UINT WINAPI GetCurrentDirectoryW( UINT buflen, LPWSTR buf )
{
LPSTR xpath = HeapAlloc( GetProcessHeap(), 0, buflen+1 );
UINT ret = GetCurrentDirectoryA( buflen, xpath );
lstrcpyAtoW( buf, xpath );
if (ret < buflen) lstrcpyAtoW ( buf, xpath );
HeapFree( GetProcessHeap(), 0, xpath );
return ret;
}