Author: hbelusca Date: Fri Sep 13 22:02:07 2013 New Revision: 60083
URL: http://svn.reactos.org/svn/reactos?rev=60083&view=rev Log: [MOUNTMGR] - Clarify the code (use properly RtlPrefixUnicodeString) - 'if' level--;
Modified: trunk/reactos/drivers/filters/mountmgr/device.c trunk/reactos/drivers/filters/mountmgr/mountmgr.c trunk/reactos/drivers/filters/mountmgr/symlink.c
Modified: trunk/reactos/drivers/filters/mountmgr/device.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/de... ============================================================================== --- trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] Fri Sep 13 22:02:07 2013 @@ -555,13 +555,21 @@ }
/* 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 */
Modified: trunk/reactos/drivers/filters/mountmgr/mountmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/mo... ============================================================================== --- trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] Fri Sep 13 22:02:07 2013 @@ -169,19 +169,22 @@ } }
- /* 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 */
Modified: trunk/reactos/drivers/filters/mountmgr/symlink.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/sy... ============================================================================== --- trunk/reactos/drivers/filters/mountmgr/symlink.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filters/mountmgr/symlink.c [iso-8859-1] Fri Sep 13 22:02:07 2013 @@ -67,38 +67,35 @@ 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)) - { - /* 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 - { - /* 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); - } + /* 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); }
/* Return string */