bug 498844 - need _wchdir for updater (in shunt) r=dougt

This commit is contained in:
Brad Lassey 2009-07-08 11:46:36 -04:00
Родитель 06262a54a5
Коммит e3456fed1e
3 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -130,6 +130,7 @@ unsigned int ExpandEnvironmentStringsW(const unsigned short* lpSrc,
unsigned short * _wgetcwd(unsigned short* dir, unsigned long size); unsigned short * _wgetcwd(unsigned short* dir, unsigned long size);
unsigned short *_wfullpath( unsigned short *absPath, const unsigned short *relPath, unsigned long maxLength ); unsigned short *_wfullpath( unsigned short *absPath, const unsigned short *relPath, unsigned long maxLength );
int _unlink(const char *filename ); int _unlink(const char *filename );
int _wchdir(const unsigned short* path);
/* The time stuff should be defined here, but it can't be because it /* The time stuff should be defined here, but it can't be because it
is already defined in time.h. is already defined in time.h.

Просмотреть файл

@ -6,6 +6,7 @@ SetEnvironmentVariableW
_unlink _unlink
_wfullpath _wfullpath
_wgetcwd _wgetcwd
_wchdir
abort abort
clock clock
errno errno

Просмотреть файл

@ -115,10 +115,21 @@ int errno = 0;
unsigned short * _wgetcwd(unsigned short * dir, unsigned long size) unsigned short * _wgetcwd(unsigned short * dir, unsigned long size)
{ {
if (!dir)
return 0;
unsigned short tmp[MAX_PATH] = {0};
GetEnvironmentVariableW(L"CWD", tmp, size);
if (tmp && tmp[0]) {
if (wcslen(tmp) > size)
return 0;
wcscpy(dir, tmp);
return dir;
}
unsigned long i; unsigned long i;
GetModuleFileName(GetModuleHandle (NULL), dir, MAX_PATH); GetModuleFileName(GetModuleHandle (NULL), dir, MAX_PATH);
for (i = _tcslen(dir); i && dir[i] != TEXT('\\'); i--) {} for (i = _tcslen(dir); i && dir[i] != TEXT('\\'); i--) {}
dir[i + 1] = TCHAR('\0'); dir[i + 1] = TCHAR('\0');
SetEnvironmentVariableW(L"CWD", dir);
return dir; return dir;
} }
@ -150,6 +161,10 @@ unsigned short *_wfullpath( unsigned short *absPath, const unsigned short *relPa
return NULL; return NULL;
} }
int _wchdir(const WCHAR* path) {
return SetEnvironmentVariableW(L"CWD", path);
}
int _unlink(const char *filename) int _unlink(const char *filename)
{ {
unsigned short wname[MAX_PATH]; unsigned short wname[MAX_PATH];