Get rid of the drive codepages and use CP_UNIXCP instead.
This commit is contained in:
parent
f95be92d24
commit
49a0224fb3
|
@ -41,7 +41,6 @@
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "winternl.h"
|
#include "winternl.h"
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "drive.h"
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
|
@ -458,7 +457,6 @@ static BOOL PROFILE_FlushFile(void)
|
||||||
if (!CurProfile->changed || !CurProfile->dos_name) return TRUE;
|
if (!CurProfile->changed || !CurProfile->dos_name) return TRUE;
|
||||||
if (!(unix_name = CurProfile->unix_name) || !(file = fopen(unix_name, "w")))
|
if (!(unix_name = CurProfile->unix_name) || !(file = fopen(unix_name, "w")))
|
||||||
{
|
{
|
||||||
int drive = toupperW(CurProfile->dos_name[0]) - 'A';
|
|
||||||
WCHAR *name, *name_lwr;
|
WCHAR *name, *name_lwr;
|
||||||
/* Try to create it in $HOME/.wine */
|
/* Try to create it in $HOME/.wine */
|
||||||
/* FIXME: this will need a more general solution */
|
/* FIXME: this will need a more general solution */
|
||||||
|
@ -472,7 +470,7 @@ static BOOL PROFILE_FlushFile(void)
|
||||||
name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
|
name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
|
||||||
strcpyW(name_lwr, name);
|
strcpyW(name_lwr, name);
|
||||||
strlwrW(name_lwr);
|
strlwrW(name_lwr);
|
||||||
WideCharToMultiByte(DRIVE_GetCodepage(drive), 0, name_lwr, -1,
|
WideCharToMultiByte(CP_UNIXCP, 0, name_lwr, -1,
|
||||||
p, sizeof(buffer) - strlen(buffer), NULL, NULL);
|
p, sizeof(buffer) - strlen(buffer), NULL, NULL);
|
||||||
HeapFree(GetProcessHeap(), 0, name_lwr);
|
HeapFree(GetProcessHeap(), 0, name_lwr);
|
||||||
|
|
||||||
|
@ -623,7 +621,7 @@ static BOOL PROFILE_Open( LPCWSTR filename )
|
||||||
name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
|
name_lwr = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(WCHAR));
|
||||||
strcpyW(name_lwr, name);
|
strcpyW(name_lwr, name);
|
||||||
strlwrW(name_lwr);
|
strlwrW(name_lwr);
|
||||||
WideCharToMultiByte(DRIVE_GetCodepage(full_name.drive), 0, name_lwr, -1,
|
WideCharToMultiByte(CP_UNIXCP, 0, name_lwr, -1,
|
||||||
p, sizeof(buffer) - strlen(buffer), NULL, NULL);
|
p, sizeof(buffer) - strlen(buffer), NULL, NULL);
|
||||||
HeapFree(GetProcessHeap(), 0, name_lwr);
|
HeapFree(GetProcessHeap(), 0, name_lwr);
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ int DIR_Init(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WCHAR szdrive[3]={drive+'A',':',0};
|
WCHAR szdrive[3]={drive+'A',':',0};
|
||||||
MultiByteToWideChar(DRIVE_GetCodepage(drive), 0, cwd, -1, longpath, MAX_PATHNAME_LEN);
|
MultiByteToWideChar(CP_UNIXCP, 0, cwd, -1, longpath, MAX_PATHNAME_LEN);
|
||||||
DRIVE_SetCurrentDrive( drive );
|
DRIVE_SetCurrentDrive( drive );
|
||||||
DRIVE_Chdir( drive, longpath );
|
DRIVE_Chdir( drive, longpath );
|
||||||
if(GetDriveTypeW(szdrive)==DRIVE_CDROM)
|
if(GetDriveTypeW(szdrive)==DRIVE_CDROM)
|
||||||
|
@ -938,8 +938,7 @@ TRACE("drive %c: root %s\n", 'A' + full_name.drive, DRIVE_GetRoot(full_name.driv
|
||||||
LPWSTR p;
|
LPWSTR p;
|
||||||
if (buflen > 3)
|
if (buflen > 3)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(DRIVE_GetCodepage(full_name.drive), 0,
|
MultiByteToWideChar(CP_UNIXCP, 0, res, -1, buffer + 3, buflen - 3);
|
||||||
res, -1, buffer + 3, buflen - 3);
|
|
||||||
buffer[buflen - 1] = 0;
|
buffer[buflen - 1] = 0;
|
||||||
}
|
}
|
||||||
for (p = buffer; *p; p++) if (*p == '/') *p = '\\';
|
for (p = buffer; *p; p++) if (*p == '/') *p = '\\';
|
||||||
|
|
|
@ -482,7 +482,7 @@ static BOOL DOSFS_AddDirEntry(DOS_DIR **dir, LPCWSTR name, LPCWSTR dosname)
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DOSFS_OpenDir_VFAT
|
* DOSFS_OpenDir_VFAT
|
||||||
*/
|
*/
|
||||||
static BOOL DOSFS_OpenDir_VFAT(UINT codepage, DOS_DIR **dir, const char *unix_path)
|
static BOOL DOSFS_OpenDir_VFAT(DOS_DIR **dir, const char *unix_path)
|
||||||
{
|
{
|
||||||
#ifdef VFAT_IOCTL_READDIR_BOTH
|
#ifdef VFAT_IOCTL_READDIR_BOTH
|
||||||
KERNEL_DIRENT de[2];
|
KERNEL_DIRENT de[2];
|
||||||
|
@ -504,13 +504,13 @@ static BOOL DOSFS_OpenDir_VFAT(UINT codepage, DOS_DIR **dir, const char *unix_pa
|
||||||
break;
|
break;
|
||||||
if (!de[0].d_reclen)
|
if (!de[0].d_reclen)
|
||||||
break;
|
break;
|
||||||
MultiByteToWideChar(codepage, 0, de[0].d_name, -1, long_name, MAX_PATH);
|
MultiByteToWideChar(CP_UNIXCP, 0, de[0].d_name, -1, long_name, MAX_PATH);
|
||||||
if (!DOSFS_ToDosFCBFormat( long_name, short_name ))
|
if (!DOSFS_ToDosFCBFormat( long_name, short_name ))
|
||||||
short_name[0] = '\0';
|
short_name[0] = '\0';
|
||||||
if (de[1].d_name[0])
|
if (de[1].d_name[0])
|
||||||
MultiByteToWideChar(codepage, 0, de[1].d_name, -1, long_name, MAX_PATH);
|
MultiByteToWideChar(CP_UNIXCP, 0, de[1].d_name, -1, long_name, MAX_PATH);
|
||||||
else
|
else
|
||||||
MultiByteToWideChar(codepage, 0, de[0].d_name, -1, long_name, MAX_PATH);
|
MultiByteToWideChar(CP_UNIXCP, 0, de[0].d_name, -1, long_name, MAX_PATH);
|
||||||
r = DOSFS_AddDirEntry(dir, long_name, short_name );
|
r = DOSFS_AddDirEntry(dir, long_name, short_name );
|
||||||
if(!r)
|
if(!r)
|
||||||
break;
|
break;
|
||||||
|
@ -533,7 +533,7 @@ static BOOL DOSFS_OpenDir_VFAT(UINT codepage, DOS_DIR **dir, const char *unix_pa
|
||||||
*
|
*
|
||||||
* Now use the standard opendir/readdir interface
|
* Now use the standard opendir/readdir interface
|
||||||
*/
|
*/
|
||||||
static BOOL DOSFS_OpenDir_Normal( UINT codepage, DOS_DIR **dir, const char *unix_path )
|
static BOOL DOSFS_OpenDir_Normal( DOS_DIR **dir, const char *unix_path )
|
||||||
{
|
{
|
||||||
DIR *unixdir = opendir( unix_path );
|
DIR *unixdir = opendir( unix_path );
|
||||||
BOOL r = TRUE;
|
BOOL r = TRUE;
|
||||||
|
@ -548,7 +548,7 @@ static BOOL DOSFS_OpenDir_Normal( UINT codepage, DOS_DIR **dir, const char *unix
|
||||||
|
|
||||||
if(!de)
|
if(!de)
|
||||||
break;
|
break;
|
||||||
MultiByteToWideChar(codepage, 0, de->d_name, -1, long_name, MAX_PATH);
|
MultiByteToWideChar(CP_UNIXCP, 0, de->d_name, -1, long_name, MAX_PATH);
|
||||||
r = DOSFS_AddDirEntry(dir, long_name, empty_strW);
|
r = DOSFS_AddDirEntry(dir, long_name, empty_strW);
|
||||||
if(!r)
|
if(!r)
|
||||||
break;
|
break;
|
||||||
|
@ -562,7 +562,7 @@ static BOOL DOSFS_OpenDir_Normal( UINT codepage, DOS_DIR **dir, const char *unix
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DOSFS_OpenDir
|
* DOSFS_OpenDir
|
||||||
*/
|
*/
|
||||||
static DOS_DIR *DOSFS_OpenDir( UINT codepage, const char *unix_path )
|
static DOS_DIR *DOSFS_OpenDir( const char *unix_path )
|
||||||
{
|
{
|
||||||
const int init_size = 0x100;
|
const int init_size = 0x100;
|
||||||
DOS_DIR *dir = HeapAlloc( GetProcessHeap(), 0, sizeof(*dir) + init_size*sizeof (WCHAR));
|
DOS_DIR *dir = HeapAlloc( GetProcessHeap(), 0, sizeof(*dir) + init_size*sizeof (WCHAR));
|
||||||
|
@ -582,10 +582,10 @@ static DOS_DIR *DOSFS_OpenDir( UINT codepage, const char *unix_path )
|
||||||
directory and mask in several other places */
|
directory and mask in several other places */
|
||||||
if (!*unix_path) unix_path = "/";
|
if (!*unix_path) unix_path = "/";
|
||||||
|
|
||||||
r = DOSFS_OpenDir_VFAT( codepage, &dir, unix_path);
|
r = DOSFS_OpenDir_VFAT( &dir, unix_path);
|
||||||
|
|
||||||
if(!r)
|
if(!r)
|
||||||
r = DOSFS_OpenDir_Normal( codepage, &dir, unix_path);
|
r = DOSFS_OpenDir_Normal( &dir, unix_path);
|
||||||
|
|
||||||
if(!r)
|
if(!r)
|
||||||
{
|
{
|
||||||
|
@ -768,7 +768,7 @@ BOOL DOSFS_FindUnixName( const DOS_FULL_NAME *path, LPCWSTR name, char *long_buf
|
||||||
|
|
||||||
if (!DOSFS_ToDosFCBFormat( name, dos_name )) dos_name[0] = '\0';
|
if (!DOSFS_ToDosFCBFormat( name, dos_name )) dos_name[0] = '\0';
|
||||||
|
|
||||||
if (!(dir = DOSFS_OpenDir( DRIVE_GetCodepage(path->drive), path->long_name )))
|
if (!(dir = DOSFS_OpenDir( path->long_name )))
|
||||||
{
|
{
|
||||||
WARN("(%s,%s): can't open dir: %s\n",
|
WARN("(%s,%s): can't open dir: %s\n",
|
||||||
path->long_name, debugstr_w(name), strerror(errno) );
|
path->long_name, debugstr_w(name), strerror(errno) );
|
||||||
|
@ -802,8 +802,7 @@ BOOL DOSFS_FindUnixName( const DOS_FULL_NAME *path, LPCWSTR name, char *long_buf
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
if (long_buf) WideCharToMultiByte(DRIVE_GetCodepage(path->drive), 0,
|
if (long_buf) WideCharToMultiByte(CP_UNIXCP, 0, long_name, -1, long_buf, long_len, NULL, NULL);
|
||||||
long_name, -1, long_buf, long_len, NULL, NULL);
|
|
||||||
if (short_buf)
|
if (short_buf)
|
||||||
{
|
{
|
||||||
if (short_name)
|
if (short_name)
|
||||||
|
@ -1052,7 +1051,7 @@ static int DOSFS_GetPathDrive( LPCWSTR *name )
|
||||||
BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last, DOS_FULL_NAME *full )
|
BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last, DOS_FULL_NAME *full )
|
||||||
{
|
{
|
||||||
BOOL found;
|
BOOL found;
|
||||||
UINT flags, codepage;
|
UINT flags;
|
||||||
char *p_l, *root;
|
char *p_l, *root;
|
||||||
LPWSTR p_s;
|
LPWSTR p_s;
|
||||||
static const WCHAR driveA_rootW[] = {'A',':','\\',0};
|
static const WCHAR driveA_rootW[] = {'A',':','\\',0};
|
||||||
|
@ -1068,7 +1067,6 @@ BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last, DOS_FULL_NAME *full )
|
||||||
|
|
||||||
if ((full->drive = DOSFS_GetPathDrive( &name )) == -1) return FALSE;
|
if ((full->drive = DOSFS_GetPathDrive( &name )) == -1) return FALSE;
|
||||||
flags = DRIVE_GetFlags( full->drive );
|
flags = DRIVE_GetFlags( full->drive );
|
||||||
codepage = DRIVE_GetCodepage(full->drive);
|
|
||||||
|
|
||||||
lstrcpynA( full->long_name, DRIVE_GetRoot( full->drive ),
|
lstrcpynA( full->long_name, DRIVE_GetRoot( full->drive ),
|
||||||
sizeof(full->long_name) );
|
sizeof(full->long_name) );
|
||||||
|
@ -1156,7 +1154,7 @@ BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last, DOS_FULL_NAME *full )
|
||||||
/* under the same short name. */
|
/* under the same short name. */
|
||||||
if (flags & DRIVE_CASE_SENSITIVE) wch = tolowerW(*name);
|
if (flags & DRIVE_CASE_SENSITIVE) wch = tolowerW(*name);
|
||||||
else wch = *name;
|
else wch = *name;
|
||||||
p_l += WideCharToMultiByte(codepage, 0, &wch, 1, p_l, 2, NULL, NULL);
|
p_l += WideCharToMultiByte(CP_UNIXCP, 0, &wch, 1, p_l, 2, NULL, NULL);
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
/* Ignore trailing dots and spaces */
|
/* Ignore trailing dots and spaces */
|
||||||
|
@ -1362,7 +1360,6 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
|
||||||
const char *root;
|
const char *root;
|
||||||
LPWSTR p;
|
LPWSTR p;
|
||||||
int drive;
|
int drive;
|
||||||
UINT codepage;
|
|
||||||
DWORD ret, len = 0;
|
DWORD ret, len = 0;
|
||||||
|
|
||||||
if (!shortpath) {
|
if (!shortpath) {
|
||||||
|
@ -1387,9 +1384,8 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
|
||||||
|
|
||||||
root = full_name.long_name;
|
root = full_name.long_name;
|
||||||
drive = DRIVE_FindDriveRoot(&root);
|
drive = DRIVE_FindDriveRoot(&root);
|
||||||
codepage = DRIVE_GetCodepage(drive);
|
|
||||||
|
|
||||||
ret = MultiByteToWideChar(codepage, 0, root, -1, NULL, 0);
|
ret = MultiByteToWideChar(CP_UNIXCP, 0, root, -1, NULL, 0);
|
||||||
ret += 3; /* A:\ */
|
ret += 3; /* A:\ */
|
||||||
/* reproduce terminating slash */
|
/* reproduce terminating slash */
|
||||||
if (ret > 4) /* if not drive root */
|
if (ret > 4) /* if not drive root */
|
||||||
|
@ -1403,7 +1399,7 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
|
||||||
{
|
{
|
||||||
longpath[0] = 'A' + drive;
|
longpath[0] = 'A' + drive;
|
||||||
longpath[1] = ':';
|
longpath[1] = ':';
|
||||||
MultiByteToWideChar(codepage, 0, root, -1, longpath + 2, longlen - 2);
|
MultiByteToWideChar(CP_UNIXCP, 0, root, -1, longpath + 2, longlen - 2);
|
||||||
for (p = longpath; *p; p++) if (*p == '/') *p = '\\';
|
for (p = longpath; *p; p++) if (*p == '/') *p = '\\';
|
||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
|
@ -1541,8 +1537,7 @@ static DWORD DOSFS_DoGetFullPathName( LPCWSTR name, DWORD len, LPWSTR result )
|
||||||
p_l = full_name.long_name + strlen(root);
|
p_l = full_name.long_name + strlen(root);
|
||||||
}
|
}
|
||||||
/* append long name (= unix name) to drive */
|
/* append long name (= unix name) to drive */
|
||||||
MultiByteToWideChar(DRIVE_GetCodepage(drive), 0, p_l, -1,
|
MultiByteToWideChar(CP_UNIXCP, 0, p_l, -1, full_name.short_name + 2, MAX_PATHNAME_LEN - 3);
|
||||||
full_name.short_name + 2, MAX_PATHNAME_LEN - 3);
|
|
||||||
/* append name to treat */
|
/* append name to treat */
|
||||||
namelen= strlenW(full_name.short_name);
|
namelen= strlenW(full_name.short_name);
|
||||||
p = (LPWSTR)name;
|
p = (LPWSTR)name;
|
||||||
|
@ -1850,7 +1845,7 @@ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the file attributes */
|
/* Check the file attributes */
|
||||||
WideCharToMultiByte(DRIVE_GetCodepage(info->drive), 0, long_name, -1,
|
WideCharToMultiByte(CP_UNIXCP, 0, long_name, -1,
|
||||||
p, sizeof(buffer) - (int)(p - buffer), NULL, NULL);
|
p, sizeof(buffer) - (int)(p - buffer), NULL, NULL);
|
||||||
if (!FILE_Stat( buffer, &fileinfo, &is_symlink ))
|
if (!FILE_Stat( buffer, &fileinfo, &is_symlink ))
|
||||||
{
|
{
|
||||||
|
@ -1937,7 +1932,7 @@ int DOSFS_FindNext( const char *path, const char *short_mask,
|
||||||
info.attr = attr;
|
info.attr = attr;
|
||||||
info.drive = drive;
|
info.drive = drive;
|
||||||
info.cur_pos = 0;
|
info.cur_pos = 0;
|
||||||
info.u.dos_dir = DOSFS_OpenDir( DRIVE_GetCodepage(drive), info.path );
|
info.u.dos_dir = DOSFS_OpenDir( info.path );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2012,7 +2007,6 @@ HANDLE WINAPI FindFirstFileExW(
|
||||||
WIN32_FIND_DATAW * data = (WIN32_FIND_DATAW *) lpFindFileData;
|
WIN32_FIND_DATAW * data = (WIN32_FIND_DATAW *) lpFindFileData;
|
||||||
char *p;
|
char *p;
|
||||||
INT long_mask_len;
|
INT long_mask_len;
|
||||||
UINT codepage;
|
|
||||||
|
|
||||||
data->dwReserved0 = data->dwReserved1 = 0x0;
|
data->dwReserved0 = data->dwReserved1 = 0x0;
|
||||||
if (lpFileName[0] == '\\' && lpFileName[1] == '\\')
|
if (lpFileName[0] == '\\' && lpFileName[1] == '\\')
|
||||||
|
@ -2048,19 +2042,18 @@ HANDLE WINAPI FindFirstFileExW(
|
||||||
info->path = HeapAlloc( GetProcessHeap(), 0, strlen(full_name.long_name)+1 );
|
info->path = HeapAlloc( GetProcessHeap(), 0, strlen(full_name.long_name)+1 );
|
||||||
strcpy( info->path, full_name.long_name );
|
strcpy( info->path, full_name.long_name );
|
||||||
|
|
||||||
codepage = DRIVE_GetCodepage(full_name.drive);
|
|
||||||
p = strrchr( info->path, '/' );
|
p = strrchr( info->path, '/' );
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
long_mask_len = MultiByteToWideChar(codepage, 0, p, -1, NULL, 0);
|
long_mask_len = MultiByteToWideChar(CP_UNIXCP, 0, p, -1, NULL, 0);
|
||||||
info->long_mask = HeapAlloc( GetProcessHeap(), 0, long_mask_len * sizeof(WCHAR) );
|
info->long_mask = HeapAlloc( GetProcessHeap(), 0, long_mask_len * sizeof(WCHAR) );
|
||||||
MultiByteToWideChar(codepage, 0, p, -1, info->long_mask, long_mask_len);
|
MultiByteToWideChar(CP_UNIXCP, 0, p, -1, info->long_mask, long_mask_len);
|
||||||
|
|
||||||
info->short_mask = NULL;
|
info->short_mask = NULL;
|
||||||
info->attr = 0xff;
|
info->attr = 0xff;
|
||||||
info->drive = full_name.drive;
|
info->drive = full_name.drive;
|
||||||
info->cur_pos = 0;
|
info->cur_pos = 0;
|
||||||
|
|
||||||
info->u.dos_dir = DOSFS_OpenDir( codepage, info->path );
|
info->u.dos_dir = DOSFS_OpenDir( info->path );
|
||||||
}
|
}
|
||||||
if (!FindNextFileW( (HANDLE) info, data ))
|
if (!FindNextFileW( (HANDLE) info, data ))
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,7 +90,6 @@ typedef struct
|
||||||
DWORD serial_conf; /* drive serial number as cfg'd in wine config */
|
DWORD serial_conf; /* drive serial number as cfg'd in wine config */
|
||||||
UINT type; /* drive type */
|
UINT type; /* drive type */
|
||||||
UINT flags; /* drive flags */
|
UINT flags; /* drive flags */
|
||||||
UINT codepage; /* drive code page */
|
|
||||||
dev_t dev; /* unix device number */
|
dev_t dev; /* unix device number */
|
||||||
ino_t ino; /* unix inode number */
|
ino_t ino; /* unix inode number */
|
||||||
} DOSDRIVE;
|
} DOSDRIVE;
|
||||||
|
@ -199,7 +198,6 @@ int DRIVE_Init(void)
|
||||||
UNICODE_STRING nameW;
|
UNICODE_STRING nameW;
|
||||||
|
|
||||||
static const WCHAR PathW[] = {'P','a','t','h',0};
|
static const WCHAR PathW[] = {'P','a','t','h',0};
|
||||||
static const WCHAR CodepageW[] = {'C','o','d','e','p','a','g','e',0};
|
|
||||||
static const WCHAR LabelW[] = {'L','a','b','e','l',0};
|
static const WCHAR LabelW[] = {'L','a','b','e','l',0};
|
||||||
static const WCHAR SerialW[] = {'S','e','r','i','a','l',0};
|
static const WCHAR SerialW[] = {'S','e','r','i','a','l',0};
|
||||||
static const WCHAR TypeW[] = {'T','y','p','e',0};
|
static const WCHAR TypeW[] = {'T','y','p','e',0};
|
||||||
|
@ -223,14 +221,6 @@ int DRIVE_Init(void)
|
||||||
nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
|
nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
|
||||||
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
||||||
|
|
||||||
/* Get the code page number */
|
|
||||||
RtlInitUnicodeString( &nameW, CodepageW );
|
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
|
||||||
{
|
|
||||||
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
|
||||||
drive->codepage = strtolW( data, NULL, 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the root path */
|
/* Get the root path */
|
||||||
RtlInitUnicodeString( &nameW, PathW );
|
RtlInitUnicodeString( &nameW, PathW );
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||||
|
@ -243,19 +233,19 @@ int DRIVE_Init(void)
|
||||||
|
|
||||||
if (path[0] == '/')
|
if (path[0] == '/')
|
||||||
{
|
{
|
||||||
len = WideCharToMultiByte(drive->codepage, 0, path, -1, NULL, 0, NULL, NULL);
|
len = WideCharToMultiByte(CP_UNIXCP, 0, path, -1, NULL, 0, NULL, NULL);
|
||||||
drive->root = HeapAlloc(GetProcessHeap(), 0, len);
|
drive->root = HeapAlloc(GetProcessHeap(), 0, len);
|
||||||
WideCharToMultiByte(drive->codepage, 0, path, -1, drive->root, len, NULL, NULL);
|
WideCharToMultiByte(CP_UNIXCP, 0, path, -1, drive->root, len, NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* relative paths are relative to config dir */
|
/* relative paths are relative to config dir */
|
||||||
const char *config = wine_get_config_dir();
|
const char *config = wine_get_config_dir();
|
||||||
len = strlen(config);
|
len = strlen(config);
|
||||||
len += WideCharToMultiByte(drive->codepage, 0, path, -1, NULL, 0, NULL, NULL) + 2;
|
len += WideCharToMultiByte(CP_UNIXCP, 0, path, -1, NULL, 0, NULL, NULL) + 2;
|
||||||
drive->root = HeapAlloc( GetProcessHeap(), 0, len );
|
drive->root = HeapAlloc( GetProcessHeap(), 0, len );
|
||||||
len -= sprintf( drive->root, "%s/", config );
|
len -= sprintf( drive->root, "%s/", config );
|
||||||
WideCharToMultiByte(drive->codepage, 0, path, -1,
|
WideCharToMultiByte(CP_UNIXCP, 0, path, -1,
|
||||||
drive->root + strlen(drive->root), len, NULL, NULL);
|
drive->root + strlen(drive->root), len, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,9 +319,9 @@ int DRIVE_Init(void)
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||||
{
|
{
|
||||||
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||||
len = WideCharToMultiByte(drive->codepage, 0, data, -1, NULL, 0, NULL, NULL);
|
len = WideCharToMultiByte(CP_UNIXCP, 0, data, -1, NULL, 0, NULL, NULL);
|
||||||
drive->device = HeapAlloc(GetProcessHeap(), 0, len);
|
drive->device = HeapAlloc(GetProcessHeap(), 0, len);
|
||||||
WideCharToMultiByte(drive->codepage, 0, data, -1, drive->device, len, NULL, NULL);
|
WideCharToMultiByte(CP_UNIXCP, 0, data, -1, drive->device, len, NULL, NULL);
|
||||||
|
|
||||||
RtlInitUnicodeString( &nameW, ReadVolInfoW );
|
RtlInitUnicodeString( &nameW, ReadVolInfoW );
|
||||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||||
|
@ -366,10 +356,10 @@ int DRIVE_Init(void)
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
TRACE("Drive %c: path=%s type=%s label=%s serial=%08lx "
|
TRACE("Drive %c: path=%s type=%s label=%s serial=%08lx "
|
||||||
"flags=%08x codepage=%u dev=%x ino=%x\n",
|
"flags=%08x dev=%x ino=%x\n",
|
||||||
'A' + i, drive->root, debugstr_w(DRIVE_Types[drive->type]),
|
'A' + i, drive->root, debugstr_w(DRIVE_Types[drive->type]),
|
||||||
debugstr_w(drive->label_conf), drive->serial_conf, drive->flags,
|
debugstr_w(drive->label_conf), drive->serial_conf, drive->flags,
|
||||||
drive->codepage, (int)drive->dev, (int)drive->ino );
|
(int)drive->dev, (int)drive->ino );
|
||||||
}
|
}
|
||||||
|
|
||||||
next:
|
next:
|
||||||
|
@ -479,9 +469,8 @@ int DRIVE_FindDriveRoot( const char **path )
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
strcpy( buffer, *path );
|
strcpy( buffer, *path );
|
||||||
while ((p = strchr( buffer, '\\' )) != NULL)
|
for (p = buffer; *p; p++) if (*p == '\\') *p = '/';
|
||||||
*p = '/';
|
len = p - buffer;
|
||||||
len = strlen(buffer);
|
|
||||||
|
|
||||||
/* strip off trailing slashes */
|
/* strip off trailing slashes */
|
||||||
while (len > 1 && buffer[len - 1] == '/') buffer[--len] = 0;
|
while (len > 1 && buffer[len - 1] == '/') buffer[--len] = 0;
|
||||||
|
@ -541,49 +530,38 @@ int DRIVE_FindDriveRootW( LPCWSTR *path )
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
strcpyW( buffer, *path );
|
strcpyW( buffer, *path );
|
||||||
while ((p = strchrW( buffer, '\\' )) != NULL)
|
for (p = buffer; *p; p++) if (*p == '\\') *p = '/';
|
||||||
*p = '/';
|
len = p - buffer;
|
||||||
len = strlenW(buffer);
|
|
||||||
|
|
||||||
/* strip off trailing slashes */
|
/* strip off trailing slashes */
|
||||||
while (len > 1 && buffer[len - 1] == '/') buffer[--len] = 0;
|
while (len > 1 && buffer[len - 1] == '/') buffer[--len] = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int codepage = -1;
|
char buffA[MAX_PATHNAME_LEN];
|
||||||
|
|
||||||
/* Find the drive */
|
WideCharToMultiByte( CP_UNIXCP, 0, buffer, -1, buffA, sizeof(buffA), NULL, NULL );
|
||||||
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
|
if (stat( buffA, &st ) == 0 && S_ISDIR( st.st_mode ))
|
||||||
{
|
{
|
||||||
char buffA[MAX_PATHNAME_LEN];
|
/* Find the drive */
|
||||||
|
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
|
||||||
if (!DOSDrives[drive].root ||
|
|
||||||
(DOSDrives[drive].flags & DRIVE_DISABLED))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (codepage != DOSDrives[drive].codepage)
|
|
||||||
{
|
{
|
||||||
WideCharToMultiByte( DOSDrives[drive].codepage, 0, buffer, -1,
|
if (!DOSDrives[drive].root ||
|
||||||
buffA, sizeof(buffA), NULL, NULL );
|
(DOSDrives[drive].flags & DRIVE_DISABLED))
|
||||||
if (stat( buffA, &st ) == -1 || !S_ISDIR( st.st_mode ))
|
|
||||||
{
|
|
||||||
codepage = -1;
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if ((DOSDrives[drive].dev == st.st_dev) &&
|
||||||
|
(DOSDrives[drive].ino == st.st_ino))
|
||||||
|
{
|
||||||
|
static const WCHAR rootW[] = {'\\',0};
|
||||||
|
|
||||||
|
if (len == 1) len = 0; /* preserve root slash in returned path */
|
||||||
|
TRACE( "%s -> drive %c:, root=%s, name=%s\n",
|
||||||
|
debugstr_w(*path), 'A' + drive, debugstr_w(buffer), debugstr_w(*path + len));
|
||||||
|
*path += len;
|
||||||
|
if (!**path) *path = rootW;
|
||||||
|
return drive;
|
||||||
}
|
}
|
||||||
codepage = DOSDrives[drive].codepage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((DOSDrives[drive].dev == st.st_dev) &&
|
|
||||||
(DOSDrives[drive].ino == st.st_ino))
|
|
||||||
{
|
|
||||||
static const WCHAR rootW[] = {'\\',0};
|
|
||||||
|
|
||||||
if (len == 1) len = 0; /* preserve root slash in returned path */
|
|
||||||
TRACE( "%s -> drive %c:, root=%s, name=%s\n",
|
|
||||||
debugstr_w(*path), 'A' + drive, debugstr_w(buffer), debugstr_w(*path + len));
|
|
||||||
*path += len;
|
|
||||||
if (!**path) *path = rootW;
|
|
||||||
return drive;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len <= 1) return -1; /* reached root */
|
if (len <= 1) return -1; /* reached root */
|
||||||
|
@ -902,7 +880,7 @@ DWORD CDROM_Data_GetLabel(int drive, WCHAR *label)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(DOSDrives[drive].codepage, 0, (LPSTR)label_read, -1, label, 11);
|
MultiByteToWideChar(CP_UNIXCP, 0, (LPSTR)label_read, -1, label, 11);
|
||||||
label[11] = '\0';
|
label[11] = '\0';
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -988,7 +966,7 @@ LPCWSTR DRIVE_GetLabel( int drive )
|
||||||
|
|
||||||
/* FIXME: ISO9660 uses a 32 bytes long label. Should we do also? */
|
/* FIXME: ISO9660 uses a 32 bytes long label. Should we do also? */
|
||||||
if (offs != -1)
|
if (offs != -1)
|
||||||
MultiByteToWideChar(DOSDrives[drive].codepage, 0, buff+offs, 11,
|
MultiByteToWideChar(CP_UNIXCP, 0, buff+offs, 11,
|
||||||
DOSDrives[drive].label_read, 11);
|
DOSDrives[drive].label_read, 11);
|
||||||
DOSDrives[drive].label_read[11]='\0';
|
DOSDrives[drive].label_read[11]='\0';
|
||||||
read = 1;
|
read = 1;
|
||||||
|
@ -1218,16 +1196,6 @@ UINT DRIVE_GetFlags( int drive )
|
||||||
return DOSDrives[drive].flags;
|
return DOSDrives[drive].flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* DRIVE_GetCodepage
|
|
||||||
*/
|
|
||||||
UINT DRIVE_GetCodepage( int drive )
|
|
||||||
{
|
|
||||||
if ((drive < 0) || (drive >= MAX_DOS_DRIVES)) return 0;
|
|
||||||
return DOSDrives[drive].codepage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DRIVE_Chdir
|
* DRIVE_Chdir
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,7 +48,6 @@ extern LPCWSTR DRIVE_GetLabel( int drive );
|
||||||
extern DWORD DRIVE_GetSerialNumber( int drive );
|
extern DWORD DRIVE_GetSerialNumber( int drive );
|
||||||
extern int DRIVE_SetSerialNumber( int drive, DWORD serial );
|
extern int DRIVE_SetSerialNumber( int drive, DWORD serial );
|
||||||
extern UINT DRIVE_GetFlags( int drive );
|
extern UINT DRIVE_GetFlags( int drive );
|
||||||
extern UINT DRIVE_GetCodepage( int drive );
|
|
||||||
extern int DRIVE_Chdir( int drive, LPCWSTR path );
|
extern int DRIVE_Chdir( int drive, LPCWSTR path );
|
||||||
extern int DRIVE_Disable( int drive );
|
extern int DRIVE_Disable( int drive );
|
||||||
extern int DRIVE_Enable( int drive );
|
extern int DRIVE_Enable( int drive );
|
||||||
|
|
Loading…
Reference in New Issue