* cygpath.cc (get_special_folder): Fetch path as WCHAR and convert
using my_wcstombs. (get_user_folder): Remove. (do_sysfolders): Use get_special_folder instead of get_user_folder. Fetch system paths as WCHAR and convert using my_wcstombs.
This commit is contained in:
parent
e710872955
commit
175e39bb7f
@ -1,3 +1,11 @@
|
|||||||
|
2009-10-15 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* cygpath.cc (get_special_folder): Fetch path as WCHAR and convert
|
||||||
|
using my_wcstombs.
|
||||||
|
(get_user_folder): Remove.
|
||||||
|
(do_sysfolders): Use get_special_folder instead of get_user_folder.
|
||||||
|
Fetch system paths as WCHAR and convert using my_wcstombs.
|
||||||
|
|
||||||
2009-10-12 Corinna Vinschen <corinna@vinschen.de>
|
2009-10-12 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* kill.cc (main): Skip to PID loop on invalid option to handle
|
* kill.cc (main): Skip to PID loop on invalid option to handle
|
||||||
|
@ -558,45 +558,46 @@ get_mixed_name (const char* filename)
|
|||||||
static bool
|
static bool
|
||||||
get_special_folder (char* path, int id)
|
get_special_folder (char* path, int id)
|
||||||
{
|
{
|
||||||
path[0] = 0;
|
WCHAR wpath[MAX_PATH];
|
||||||
|
|
||||||
|
path[0] = '\0';
|
||||||
|
wpath[0] = L'\0';
|
||||||
LPITEMIDLIST pidl = 0;
|
LPITEMIDLIST pidl = 0;
|
||||||
if (SHGetSpecialFolderLocation (NULL, id, &pidl) != S_OK)
|
if (SHGetSpecialFolderLocation (NULL, id, &pidl) != S_OK)
|
||||||
return false;
|
return false;
|
||||||
if (!SHGetPathFromIDList (pidl, path) || !path[0])
|
if (!SHGetPathFromIDListW (pidl, wpath) || !wpath[0])
|
||||||
return false;
|
return false;
|
||||||
|
my_wcstombs (path, wpath, PATH_MAX);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
get_user_folder (char* path, int id, int allid)
|
|
||||||
{
|
|
||||||
get_special_folder (path, allusers_flag ? allid : id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_sysfolders (char option)
|
do_sysfolders (char option)
|
||||||
{
|
{
|
||||||
char *buf, buf1[MAX_PATH], buf2[PATH_MAX];
|
char *buf, buf1[PATH_MAX], buf2[PATH_MAX];
|
||||||
|
WCHAR wbuf[MAX_PATH];
|
||||||
DWORD len = MAX_PATH;
|
DWORD len = MAX_PATH;
|
||||||
WIN32_FIND_DATA w32_fd;
|
WIN32_FIND_DATAW w32_fd;
|
||||||
HINSTANCE k32;
|
HINSTANCE k32;
|
||||||
BOOL (*GetProfilesDirectoryAPtr) (LPSTR, LPDWORD) = 0;
|
BOOL (*GetProfilesDirectoryAPtrW) (LPWSTR, LPDWORD) = 0;
|
||||||
|
|
||||||
buf = buf1;
|
buf = buf1;
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
case 'D':
|
case 'D':
|
||||||
get_user_folder (buf, CSIDL_DESKTOPDIRECTORY,
|
get_special_folder (buf, allusers_flag ? CSIDL_COMMON_DESKTOPDIRECTORY
|
||||||
CSIDL_COMMON_DESKTOPDIRECTORY);
|
: CSIDL_DESKTOPDIRECTORY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
get_user_folder (buf, CSIDL_PROGRAMS, CSIDL_COMMON_PROGRAMS);
|
get_special_folder (buf, allusers_flag ? CSIDL_COMMON_PROGRAMS
|
||||||
|
: CSIDL_PROGRAMS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'O':
|
case 'O':
|
||||||
get_user_folder (buf, CSIDL_PERSONAL, CSIDL_COMMON_DOCUMENTS);
|
get_special_folder (buf, allusers_flag ? CSIDL_COMMON_DOCUMENTS
|
||||||
|
: CSIDL_PERSONAL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F':
|
case 'F':
|
||||||
@ -616,25 +617,35 @@ do_sysfolders (char option)
|
|||||||
case 'H':
|
case 'H':
|
||||||
k32 = LoadLibrary ("userenv");
|
k32 = LoadLibrary ("userenv");
|
||||||
if (k32)
|
if (k32)
|
||||||
GetProfilesDirectoryAPtr = (BOOL (*) (LPSTR, LPDWORD))
|
GetProfilesDirectoryAPtrW = (BOOL (*) (LPWSTR, LPDWORD))
|
||||||
GetProcAddress (k32, "GetProfilesDirectoryA");
|
GetProcAddress (k32, "GetProfilesDirectoryW");
|
||||||
if (GetProfilesDirectoryAPtr)
|
if (GetProfilesDirectoryAPtrW)
|
||||||
(*GetProfilesDirectoryAPtr) (buf, &len);
|
(*GetProfilesDirectoryAPtrW) (wbuf, &len);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetWindowsDirectory (buf, MAX_PATH);
|
GetWindowsDirectoryW (wbuf, MAX_PATH);
|
||||||
strcat (buf, "\\Profiles");
|
wcscat (wbuf, L"\\Profiles");
|
||||||
}
|
}
|
||||||
|
my_wcstombs (buf, wbuf, PATH_MAX);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
GetSystemDirectory (buf, MAX_PATH);
|
{
|
||||||
FindFirstFile (buf, &w32_fd);
|
HANDLE fh;
|
||||||
strcpy (strrchr (buf, '\\') + 1, w32_fd.cFileName);
|
|
||||||
|
GetSystemDirectoryW (wbuf, MAX_PATH);
|
||||||
|
if ((fh = FindFirstFileW (wbuf, &w32_fd)) != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
FindClose (fh);
|
||||||
|
wcscpy (wcsrchr (wbuf, L'\\') + 1, w32_fd.cFileName);
|
||||||
|
}
|
||||||
|
my_wcstombs (buf, wbuf, PATH_MAX);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
GetWindowsDirectory (buf, MAX_PATH);
|
GetWindowsDirectoryW (wbuf, MAX_PATH);
|
||||||
|
my_wcstombs (buf, wbuf, PATH_MAX);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user