mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:19:49 +00:00
winecfg: Store the drive serial number as a number instead of a string.
This commit is contained in:
parent
3b6daf2512
commit
6483f2f201
4 changed files with 27 additions and 36 deletions
|
@ -87,20 +87,20 @@ long drive_available_mask(char letter)
|
|||
return result;
|
||||
}
|
||||
|
||||
BOOL add_drive(const char letter, const char *targetpath, const char *label, const char *serial, unsigned int type)
|
||||
BOOL add_drive(const char letter, const char *targetpath, const char *label, DWORD serial, unsigned int type)
|
||||
{
|
||||
int driveIndex = letter_to_index(letter);
|
||||
|
||||
if(drives[driveIndex].in_use)
|
||||
return FALSE;
|
||||
|
||||
WINE_TRACE("letter == '%c', unixpath == '%s', label == '%s', serial == '%s', type == %d\n",
|
||||
WINE_TRACE("letter == '%c', unixpath == '%s', label == '%s', serial == %08x, type == %d\n",
|
||||
letter, targetpath, label, serial, type);
|
||||
|
||||
drives[driveIndex].letter = toupper(letter);
|
||||
drives[driveIndex].unixpath = strdupA(targetpath);
|
||||
drives[driveIndex].label = strdupA(label);
|
||||
drives[driveIndex].serial = strdupA(serial);
|
||||
drives[driveIndex].serial = serial;
|
||||
drives[driveIndex].type = type;
|
||||
drives[driveIndex].in_use = TRUE;
|
||||
|
||||
|
@ -114,9 +114,7 @@ void delete_drive(struct drive *d)
|
|||
d->unixpath = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, d->label);
|
||||
d->label = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, d->serial);
|
||||
d->serial = NULL;
|
||||
|
||||
d->serial = 0;
|
||||
d->in_use = FALSE;
|
||||
}
|
||||
|
||||
|
@ -198,20 +196,22 @@ static void set_drive_label( char letter, const char *label )
|
|||
}
|
||||
|
||||
/* set the drive serial number via a .windows-serial file */
|
||||
static void set_drive_serial( char letter, const char *serial )
|
||||
static void set_drive_serial( char letter, DWORD serial )
|
||||
{
|
||||
char filename[] = "a:\\.windows-serial";
|
||||
HANDLE hFile;
|
||||
|
||||
filename[0] = letter;
|
||||
WINE_TRACE("Putting serial number of '%s' into file '%s'\n", serial, filename);
|
||||
WINE_TRACE("Putting serial number of %08x into file '%s'\n", serial, filename);
|
||||
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD w;
|
||||
WriteFile(hFile, serial, strlen(serial), &w, NULL);
|
||||
WriteFile(hFile, "\n", 1, &w, NULL);
|
||||
char buffer[16];
|
||||
|
||||
sprintf( buffer, "%X\n", serial );
|
||||
WriteFile(hFile, buffer, strlen(buffer), &w, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
}
|
||||
|
@ -281,15 +281,13 @@ void load_drives(void)
|
|||
{
|
||||
drives[i].letter = 'A' + i;
|
||||
drives[i].in_use = FALSE;
|
||||
drives[i].serial = 0;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, drives[i].unixpath);
|
||||
drives[i].unixpath = NULL;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, drives[i].label);
|
||||
drives[i].label = NULL;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, drives[i].serial);
|
||||
drives[i].serial = NULL;
|
||||
}
|
||||
|
||||
/* work backwards through the result of GetLogicalDriveStrings */
|
||||
|
@ -297,7 +295,6 @@ void load_drives(void)
|
|||
{
|
||||
char volname[512]; /* volume name */
|
||||
DWORD serial;
|
||||
char serialstr[256];
|
||||
char rootpath[256];
|
||||
char simplepath[3];
|
||||
int pathlen;
|
||||
|
@ -346,9 +343,7 @@ void load_drives(void)
|
|||
c = targetpath;
|
||||
do if (*c == '\\') *c = '/'; while (*c++);
|
||||
|
||||
snprintf(serialstr, sizeof(serialstr), "%X", serial);
|
||||
WINE_TRACE("serialstr: '%s'\n", serialstr);
|
||||
add_drive(*devices, targetpath, volname, serialstr, get_drive_type(devices[0]) );
|
||||
add_drive(*devices, targetpath, volname, serial, get_drive_type(devices[0]) );
|
||||
|
||||
len -= strlen(devices);
|
||||
devices += strlen(devices);
|
||||
|
@ -386,7 +381,7 @@ void load_drives(void)
|
|||
buff[cnt] = '\0';
|
||||
|
||||
WINE_TRACE("found broken symlink %s -> %s\n", path, buff);
|
||||
add_drive('A' + i, buff, "", "0", DRIVE_UNKNOWN);
|
||||
add_drive('A' + i, buff, "", 0, DRIVE_UNKNOWN);
|
||||
|
||||
drivecount++;
|
||||
}
|
||||
|
@ -410,7 +405,6 @@ void apply_drive_changes(void)
|
|||
DWORD maxComponentLength;
|
||||
DWORD fileSystemFlags;
|
||||
CHAR fileSystemName[128];
|
||||
char newSerialNumberText[32];
|
||||
int retval;
|
||||
BOOL defineDevice;
|
||||
|
||||
|
@ -517,8 +511,7 @@ void apply_drive_changes(void)
|
|||
if (drives[i].label && strcmp(drives[i].label, volumeNameBuffer))
|
||||
set_drive_label( drives[i].letter, drives[i].label );
|
||||
|
||||
snprintf(newSerialNumberText, sizeof(newSerialNumberText), "%X", serialNumber);
|
||||
if (drives[i].serial && drives[i].serial[0] && strcmp(drives[i].serial, newSerialNumberText))
|
||||
if (drives[i].serial != serialNumber)
|
||||
set_drive_serial( drives[i].letter, drives[i].serial );
|
||||
|
||||
set_drive_type( drives[i].letter, drives[i].type );
|
||||
|
|
|
@ -233,7 +233,7 @@ static void ensure_root_is_mapped(void)
|
|||
{
|
||||
if (!drives[letter - 'A'].in_use)
|
||||
{
|
||||
add_drive(letter, "/", "System", "0", DRIVE_FIXED);
|
||||
add_drive(letter, "/", "System", 0, DRIVE_FIXED);
|
||||
WINE_TRACE("allocated drive %c as the root drive\n", letter);
|
||||
break;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ static void ensure_home_is_mapped(void)
|
|||
{
|
||||
if (!drives[letter - 'A'].in_use)
|
||||
{
|
||||
add_drive(letter, home, "Home", "0", DRIVE_FIXED);
|
||||
add_drive(letter, home, "Home", 0, DRIVE_FIXED);
|
||||
WINE_TRACE("allocated drive %c as the user's home directory\n", letter);
|
||||
break;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ static void ensure_drive_c_is_mapped(void)
|
|||
|
||||
if (stat(drive_c_dir, &buf) == 0)
|
||||
{
|
||||
add_drive('C', "../drive_c", "Virtual Windows Drive", "0", DRIVE_FIXED);
|
||||
add_drive('C', "../drive_c", "Virtual Windows Drive", 0, DRIVE_FIXED);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ int autodetect_drives(void)
|
|||
|
||||
WINE_TRACE("adding drive %c for %s, type %s with label %s\n", letter, ent->mnt_dir, ent->mnt_type,label);
|
||||
|
||||
add_drive(letter, ent->mnt_dir, label, "0", type);
|
||||
add_drive(letter, ent->mnt_dir, label, 0, type);
|
||||
|
||||
/* working_mask is a map of the drive letters still available. */
|
||||
working_mask &= ~DRIVE_MASK_BIT(letter);
|
||||
|
|
|
@ -314,9 +314,9 @@ static void on_add_click(HWND dialog)
|
|||
char label[64];
|
||||
LoadStringA (GetModuleHandle (NULL), IDS_SYSTEM_DRIVE_LABEL, label,
|
||||
sizeof(label)/sizeof(label[0]));
|
||||
add_drive(new, "../drive_c", label, "", DRIVE_FIXED);
|
||||
add_drive(new, "../drive_c", label, 0, DRIVE_FIXED);
|
||||
}
|
||||
else add_drive(new, "/", "", "", DRIVE_UNKNOWN);
|
||||
else add_drive(new, "/", "", 0, DRIVE_UNKNOWN);
|
||||
|
||||
fill_drives_list(dialog);
|
||||
|
||||
|
@ -378,7 +378,7 @@ static void update_controls(HWND dialog)
|
|||
char *path;
|
||||
unsigned int type;
|
||||
char *label;
|
||||
char *serial;
|
||||
char serial[16];
|
||||
const char *device;
|
||||
int i, selection = -1;
|
||||
LVITEM item;
|
||||
|
@ -437,7 +437,7 @@ static void update_controls(HWND dialog)
|
|||
set_text(dialog, IDC_EDIT_LABEL, label);
|
||||
|
||||
/* set serial edit text */
|
||||
serial = current_drive->serial;
|
||||
sprintf( serial, "%X", current_drive->serial );
|
||||
set_text(dialog, IDC_EDIT_SERIAL, serial);
|
||||
|
||||
/* TODO: get the device here to put into the edit box */
|
||||
|
@ -518,10 +518,9 @@ static void on_edit_changed(HWND dialog, WORD id)
|
|||
char *serial;
|
||||
|
||||
serial = get_text(dialog, id);
|
||||
HeapFree(GetProcessHeap(), 0, current_drive->serial);
|
||||
current_drive->serial = serial ? serial : strdupA("");
|
||||
current_drive->serial = strtoul( serial, NULL, 16 );
|
||||
|
||||
WINE_TRACE("set serial to %s\n", current_drive->serial);
|
||||
WINE_TRACE("set serial to %08x\n", current_drive->serial);
|
||||
|
||||
/* enable the apply button */
|
||||
SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
|
||||
|
@ -760,8 +759,7 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
current_drive->label = str ? str : strdupA("");
|
||||
|
||||
str = get_text(dialog, IDC_EDIT_SERIAL);
|
||||
HeapFree(GetProcessHeap(), 0, current_drive->serial);
|
||||
current_drive->serial = str ? str : strdupA("");
|
||||
current_drive->serial = strtoul( str, NULL, 16 );
|
||||
|
||||
/* TODO: we don't have a device at this point */
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ struct drive
|
|||
char letter;
|
||||
char *unixpath;
|
||||
char *label;
|
||||
char *serial;
|
||||
DWORD serial;
|
||||
DWORD type; /* one of the DRIVE_ constants from winbase.h */
|
||||
|
||||
BOOL in_use;
|
||||
|
@ -107,7 +107,7 @@ struct drive
|
|||
#define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
|
||||
|
||||
long drive_available_mask(char letter);
|
||||
BOOL add_drive(const char letter, const char *targetpath, const char *label, const char *serial, unsigned int type);
|
||||
BOOL add_drive(const char letter, const char *targetpath, const char *label, DWORD serial, unsigned int type);
|
||||
void delete_drive(struct drive *pDrive);
|
||||
void apply_drive_changes(void);
|
||||
BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath);
|
||||
|
|
Loading…
Reference in a new issue