mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[CRT]
Improve _getdrive and _tchdir. Patch by devpao (devotip at tiscali dot it), small formatting change by me. See issue #5848 for more details. svn path=/trunk/; revision=50861
This commit is contained in:
parent
e9af1d723f
commit
39a0c140c2
2 changed files with 12 additions and 6 deletions
|
@ -17,10 +17,13 @@ int _tchdir(const _TCHAR* _path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the drive-specific current directory variable */
|
/* Update the drive-specific current directory variable */
|
||||||
if (GetCurrentDirectoryW(MAX_PATH, newdir) && newdir[1] == L':')
|
if (GetCurrentDirectoryW(MAX_PATH, newdir) >= 2)
|
||||||
{
|
{
|
||||||
WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':', L'\0' };
|
if (newdir[1] == L':')
|
||||||
SetEnvironmentVariableW(envvar, newdir);
|
{
|
||||||
|
WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':', L'\0' };
|
||||||
|
SetEnvironmentVariableW(envvar, newdir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -20,9 +20,12 @@
|
||||||
int _getdrive(void)
|
int _getdrive(void)
|
||||||
{
|
{
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
if (GetCurrentDirectoryW( MAX_PATH, buffer ) &&
|
if (GetCurrentDirectoryW( MAX_PATH, buffer )>=2)
|
||||||
buffer[0] >= 'A' && buffer[0] <= 'z' && buffer[1] == ':')
|
{
|
||||||
return towupper(buffer[0]) - 'A' + 1;
|
buffer[0]=towupper(buffer[0]);
|
||||||
|
if (buffer[0] >= L'A' && buffer[0] <= L'Z' && buffer[1] == L':')
|
||||||
|
return buffer[0] - L'A' + 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue