mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[MOUNTMGR]
- Clarify the code (use properly RtlPrefixUnicodeString) - 'if' level--; svn path=/trunk/; revision=60083
This commit is contained in:
parent
60b1848efb
commit
a927f1d071
3 changed files with 43 additions and 35 deletions
|
@ -555,13 +555,21 @@ MountMgrNextDriveLetterWorker(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
}
|
||||
|
||||
/* Now everything is fine, start processing */
|
||||
|
||||
if (RtlPrefixUnicodeString(&DeviceFloppy, &TargetDeviceName, TRUE))
|
||||
{
|
||||
/* If the device is a floppy, start with letter A */
|
||||
DriveLetter = 'A';
|
||||
}
|
||||
else if (RtlPrefixUnicodeString(&DeviceCdRom, &TargetDeviceName, TRUE))
|
||||
{
|
||||
/* If the device is a CD-ROM, start with letter D */
|
||||
DriveLetter = 'D';
|
||||
}
|
||||
else
|
||||
{
|
||||
DriveLetter = 'C' + RtlPrefixUnicodeString(&DeviceCdRom, &TargetDeviceName, TRUE);
|
||||
/* Finally, if it's a disk, use C */
|
||||
DriveLetter = 'C';
|
||||
}
|
||||
|
||||
/* We cannot set NO drive letter */
|
||||
|
|
|
@ -169,19 +169,22 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
|
|||
}
|
||||
}
|
||||
|
||||
/* If caller didn't provide a letter, let's find one for him.
|
||||
* If device is a floppy, start with letter A
|
||||
*/
|
||||
/* If caller didn't provide a letter, let's find one for him */
|
||||
|
||||
if (RtlPrefixUnicodeString(&DeviceFloppy, DeviceName, TRUE))
|
||||
{
|
||||
/* If the device is a floppy, start with letter A */
|
||||
Letter = 'A';
|
||||
}
|
||||
else if (RtlPrefixUnicodeString(&DeviceCdRom, DeviceName, TRUE))
|
||||
{
|
||||
/* If the device is a CD-ROM, start with letter D */
|
||||
Letter = 'D';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, if device is a cd rom, then, start with D.
|
||||
* Finally, if a disk, use C
|
||||
*/
|
||||
Letter = RtlPrefixUnicodeString(&DeviceCdRom, DeviceName, TRUE) + 'C';
|
||||
/* Finally, if it's a disk, use C */
|
||||
Letter = 'C';
|
||||
}
|
||||
|
||||
/* Try to affect a letter (up to Z, ofc) until it's possible */
|
||||
|
|
|
@ -67,38 +67,35 @@ CreateStringWithGlobal(IN PUNICODE_STRING DosName,
|
|||
DosName->Length - DosDevices.Length);
|
||||
IntGlobal.Buffer[IntGlobal.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
}
|
||||
else if (RtlPrefixUnicodeString(&Global, DosName, TRUE))
|
||||
{
|
||||
/* Switch to DOS global */
|
||||
IntGlobal.Length = DosName->Length - Global.Length + DosGlobal.Length;
|
||||
IntGlobal.MaximumLength = IntGlobal.Length + sizeof(WCHAR);
|
||||
IntGlobal.Buffer = AllocatePool(IntGlobal.MaximumLength);
|
||||
if (!IntGlobal.Buffer)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
RtlCopyMemory(IntGlobal.Buffer, DosGlobal.Buffer, DosGlobal.Length);
|
||||
RtlCopyMemory(IntGlobal.Buffer + (DosGlobal.Length / sizeof(WCHAR)),
|
||||
DosName->Buffer + (Global.Length / sizeof(WCHAR)),
|
||||
DosName->Length - Global.Length);
|
||||
IntGlobal.Buffer[IntGlobal.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RtlPrefixUnicodeString(&Global, DosName, TRUE))
|
||||
/* Simply duplicate string */
|
||||
IntGlobal.Length = DosName->Length;
|
||||
IntGlobal.MaximumLength = DosName->MaximumLength;
|
||||
IntGlobal.Buffer = AllocatePool(IntGlobal.MaximumLength);
|
||||
if (!IntGlobal.Buffer)
|
||||
{
|
||||
/* Switch to DOS global */
|
||||
IntGlobal.Length = DosName->Length - Global.Length + DosGlobal.Length;
|
||||
IntGlobal.MaximumLength = IntGlobal.Length + sizeof(WCHAR);
|
||||
IntGlobal.Buffer = AllocatePool(IntGlobal.MaximumLength);
|
||||
if (!IntGlobal.Buffer)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
RtlCopyMemory(IntGlobal.Buffer, DosGlobal.Buffer, DosGlobal.Length);
|
||||
RtlCopyMemory(IntGlobal.Buffer + (DosGlobal.Length / sizeof(WCHAR)),
|
||||
DosName->Buffer + (Global.Length / sizeof(WCHAR)),
|
||||
DosName->Length - Global.Length);
|
||||
IntGlobal.Buffer[IntGlobal.Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Simply duplicate string */
|
||||
IntGlobal.Length = DosName->Length;
|
||||
IntGlobal.MaximumLength = DosName->MaximumLength;
|
||||
IntGlobal.Buffer = AllocatePool(IntGlobal.MaximumLength);
|
||||
if (!IntGlobal.Buffer)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
RtlCopyMemory(IntGlobal.Buffer, DosName->Buffer, IntGlobal.MaximumLength);
|
||||
}
|
||||
RtlCopyMemory(IntGlobal.Buffer, DosName->Buffer, IntGlobal.MaximumLength);
|
||||
}
|
||||
|
||||
/* Return string */
|
||||
|
|
Loading…
Reference in a new issue