mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[RTL]
- Formatting only (no code changes) svn path=/trunk/; revision=72557
This commit is contained in:
parent
6d4d06afbb
commit
76de8ee7ce
1 changed files with 248 additions and 224 deletions
|
@ -31,7 +31,7 @@ static USHORT
|
|||
RtlpGetCheckSum(PUNICODE_STRING Name)
|
||||
{
|
||||
USHORT Hash, Saved;
|
||||
WCHAR * CurChar;
|
||||
WCHAR* CurChar;
|
||||
USHORT Len;
|
||||
|
||||
if (Name->Length == 0)
|
||||
|
@ -46,6 +46,7 @@ RtlpGetCheckSum(PUNICODE_STRING Name)
|
|||
|
||||
CurChar = Name->Buffer;
|
||||
Hash = (*CurChar << 8) + *(CurChar + 1);
|
||||
|
||||
if (Name->Length == 2 * sizeof(WCHAR))
|
||||
{
|
||||
return Hash;
|
||||
|
@ -53,15 +54,18 @@ RtlpGetCheckSum(PUNICODE_STRING Name)
|
|||
|
||||
Saved = Hash;
|
||||
Len = 2;
|
||||
|
||||
do
|
||||
{
|
||||
CurChar = CurChar + 2;
|
||||
Hash = (Hash << 7) + *CurChar;
|
||||
Hash = (Saved >> 1) + (Hash << 8);
|
||||
|
||||
if (Len + 1 < Name->Length / sizeof(WCHAR))
|
||||
{
|
||||
Hash += *(CurChar + 1);
|
||||
}
|
||||
|
||||
Saved = Hash;
|
||||
Len += 2;
|
||||
} while (Len < Name->Length / sizeof(WCHAR));
|
||||
|
@ -73,11 +77,13 @@ static ULONG
|
|||
RtlpGetIndexLength(ULONG Index)
|
||||
{
|
||||
ULONG Length = 0;
|
||||
|
||||
while (Index)
|
||||
{
|
||||
Index /= 10;
|
||||
Length++;
|
||||
}
|
||||
|
||||
return Length ? Length : 1;
|
||||
}
|
||||
|
||||
|
@ -85,7 +91,8 @@ RtlpGetIndexLength(ULONG Index)
|
|||
/*
|
||||
* @implemented
|
||||
*/
|
||||
VOID NTAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
||||
IN BOOLEAN AllowExtendedCharacters,
|
||||
IN OUT PGENERATE_NAME_CONTEXT Context,
|
||||
|
@ -106,6 +113,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
WCHAR c;
|
||||
|
||||
StrLength = Name->Length / sizeof(WCHAR);
|
||||
|
||||
DPRINT("StrLength: %lu\n", StrLength);
|
||||
|
||||
/* Find last dot in Name */
|
||||
|
@ -156,6 +164,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
for (i = DotPos, ExtLength = 0; ExtLength < 4 && i < StrLength; i++)
|
||||
{
|
||||
c = UNICODE_NULL;
|
||||
|
||||
if (AllowExtendedCharacters)
|
||||
{
|
||||
c = RtlUpcaseUnicodeChar(Name->Buffer[i]);
|
||||
|
@ -183,6 +192,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
{
|
||||
ExtLength = 0;
|
||||
}
|
||||
|
||||
DPRINT("ExtBuffer: '%.04S'\n", ExtBuffer);
|
||||
DPRINT("ExtLength: %lu\n", ExtLength);
|
||||
|
||||
|
@ -209,6 +219,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
(Context->LastIndexValue < 999))
|
||||
{
|
||||
Context->LastIndexValue++;
|
||||
|
||||
if (Context->CheckSumInserted == FALSE &&
|
||||
Context->LastIndexValue > 9)
|
||||
{
|
||||
|
@ -220,6 +231,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
else
|
||||
{
|
||||
Context->LastIndexValue = 1;
|
||||
|
||||
if (NameLength == 0)
|
||||
{
|
||||
Context->CheckSumInserted = TRUE;
|
||||
|
@ -246,25 +258,32 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
|
||||
/* Build the short name */
|
||||
memcpy(Name8dot3->Buffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
||||
|
||||
j = CopyLength;
|
||||
|
||||
if (Context->CheckSumInserted)
|
||||
{
|
||||
Checksum = Context->Checksum;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
Name8dot3->Buffer[j++] = (Checksum & 0xF) > 9 ? (Checksum & 0xF) + L'A' - 10 : (Checksum & 0xF) + L'0';
|
||||
Checksum >>= 4;
|
||||
}
|
||||
|
||||
j = CopyLength + 4;
|
||||
}
|
||||
|
||||
Name8dot3->Buffer[j++] = L'~';
|
||||
j += IndexLength - 1;
|
||||
CurrentIndex = Context->LastIndexValue;
|
||||
|
||||
for (i = 0; i < IndexLength; i++)
|
||||
{
|
||||
Name8dot3->Buffer[j--] = (CurrentIndex % 10) + L'0';
|
||||
CurrentIndex /= 10;
|
||||
}
|
||||
|
||||
j += IndexLength + 1;
|
||||
|
||||
memcpy(Name8dot3->Buffer + j, ExtBuffer, ExtLength * sizeof(WCHAR));
|
||||
|
@ -275,6 +294,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
|
|||
/* Update context */
|
||||
Context->NameLength = (UCHAR)CopyLength;
|
||||
Context->ExtensionLength = ExtLength;
|
||||
|
||||
memcpy(Context->NameBuffer, NameBuffer, CopyLength * sizeof(WCHAR));
|
||||
memcpy(Context->ExtensionBuffer, ExtBuffer, ExtLength * sizeof(WCHAR));
|
||||
}
|
||||
|
@ -290,10 +310,9 @@ _Must_inspect_result_
|
|||
NTSYSAPI
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
RtlIsNameLegalDOS8Dot3 (
|
||||
_In_ PCUNICODE_STRING Name,
|
||||
_Inout_opt_ POEM_STRING OemName,
|
||||
_Out_opt_ PBOOLEAN NameContainsSpaces)
|
||||
RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING Name,
|
||||
IN OUT POEM_STRING OemName,
|
||||
OUT PBOOLEAN NameContainsSpaces OPTIONAL)
|
||||
{
|
||||
static const char Illegal[] = "*?<>|\"+=,;[]:/\\\345";
|
||||
int Dot = -1;
|
||||
|
@ -322,6 +341,7 @@ RtlIsNameLegalDOS8Dot3 (
|
|||
{
|
||||
if (OemName->Length != 1 && (OemName->Length != 2 || OemName->Buffer[1] != '.')) return FALSE;
|
||||
if (NameContainsSpaces) *NameContainsSpaces = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -334,10 +354,12 @@ RtlIsNameLegalDOS8Dot3 (
|
|||
if (!i || i == OemName->Length-1 || OemName->Buffer[i+1] == '.') return FALSE;
|
||||
GotSpace = TRUE;
|
||||
break;
|
||||
|
||||
case '.':
|
||||
if (Dot != -1) return FALSE;
|
||||
Dot = i;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (strchr(Illegal, OemName->Buffer[i])) return FALSE;
|
||||
break;
|
||||
|
@ -354,7 +376,9 @@ RtlIsNameLegalDOS8Dot3 (
|
|||
{
|
||||
if (Dot > 8 || (OemName->Length - Dot > 4) || Dot == OemName->Length - 1) return FALSE;
|
||||
}
|
||||
|
||||
if (NameContainsSpaces) *NameContainsSpaces = GotSpace;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue