msvcrt: Implement _wsearchenv.
This commit is contained in:
parent
7de0f1d583
commit
7d3d98eb5c
|
@ -1010,3 +1010,66 @@ void CDECL _searchenv(const char* file, const char* env, char *buf)
|
|||
penv = *end ? end + 1 : end;
|
||||
} while(1);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _wsearchenv (MSVCRT.@)
|
||||
*
|
||||
* Unicode version of _searchenv
|
||||
*/
|
||||
void CDECL _wsearchenv(const MSVCRT_wchar_t* file, const MSVCRT_wchar_t* env, MSVCRT_wchar_t *buf)
|
||||
{
|
||||
MSVCRT_wchar_t *envVal, *penv;
|
||||
MSVCRT_wchar_t curPath[MAX_PATH];
|
||||
|
||||
*buf = '\0';
|
||||
|
||||
/* Try CWD first */
|
||||
if (GetFileAttributesW( file ) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
GetFullPathNameW( file, MAX_PATH, buf, NULL );
|
||||
/* Sigh. This error is *always* set, regardless of success */
|
||||
msvcrt_set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Search given environment variable */
|
||||
envVal = _wgetenv(env);
|
||||
if (!envVal)
|
||||
{
|
||||
msvcrt_set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
penv = envVal;
|
||||
TRACE(":searching for %s in paths %s\n", debugstr_w(file), debugstr_w(envVal));
|
||||
|
||||
do
|
||||
{
|
||||
MSVCRT_wchar_t *end = penv;
|
||||
|
||||
while(*end && *end != ';') end++; /* Find end of next path */
|
||||
if (penv == end || !*penv)
|
||||
{
|
||||
msvcrt_set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
memcpy(curPath, penv, (end - penv) * sizeof(MSVCRT_wchar_t));
|
||||
if (curPath[end - penv] != '/' || curPath[end - penv] != '\\')
|
||||
{
|
||||
curPath[end - penv] = '\\';
|
||||
curPath[end - penv + 1] = '\0';
|
||||
}
|
||||
else
|
||||
curPath[end - penv] = '\0';
|
||||
|
||||
strcatW(curPath, file);
|
||||
TRACE("Checking for file %s\n", debugstr_w(curPath));
|
||||
if (GetFileAttributesW( curPath ) != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
strcpyW(buf, curPath);
|
||||
msvcrt_set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return; /* Found */
|
||||
}
|
||||
penv = *end ? end + 1 : end;
|
||||
} while(1);
|
||||
}
|
||||
|
|
|
@ -651,6 +651,7 @@ int MSVCRT__close(int);
|
|||
int MSVCRT__dup(int);
|
||||
int MSVCRT__dup2(int, int);
|
||||
int MSVCRT__pipe(int *, unsigned int, int);
|
||||
MSVCRT_wchar_t* _wgetenv(const MSVCRT_wchar_t*);
|
||||
#endif
|
||||
|
||||
#endif /* __WINE_MSVCRT_H */
|
||||
|
|
|
@ -552,7 +552,7 @@
|
|||
@ cdecl _wrename(wstr wstr)
|
||||
@ cdecl _write(long ptr long) MSVCRT__write
|
||||
@ cdecl _wrmdir(wstr)
|
||||
@ stub _wsearchenv #(wstr wstr ptr)
|
||||
@ stdcall _wsearchenv(wstr wstr ptr)
|
||||
@ cdecl _wsetlocale(long wstr) MSVCRT__wsetlocale
|
||||
@ varargs _wsopen (wstr long long) MSVCRT__wsopen
|
||||
@ stub _wspawnl #(long wstr wstr) varargs
|
||||
|
|
Loading…
Reference in New Issue