{
ANSI_STRINGFirstPart, RemainingPart, Name;
USHORT i;
PAGED_CODE();
/* Just quit if the string is empty */if (!DbcsName.Length)
returnFALSE;
/* DbcsName wasn't supposed to be started with \ */if (!LeadingBackslashPermissible && DbcsName.Buffer[0] == '\\')
returnFALSE;
/* DbcsName was allowed to be started with \, but now, remove it */elseif (LeadingBackslashPermissible && DbcsName.Buffer[0] == '\\')
{
DbcsName.Buffer = DbcsName.Buffer + 1;
DbcsName.Length = DbcsName.Length - 1;
DbcsName.MaximumLength = DbcsName.MaximumLength - 1;
}
/* Extract first part of the DbcsName to work on */FsRtlDissectDbcs(DbcsName, &FirstPart, &RemainingPart);
while (FirstPart.Length > 0)
{
/* Accept special filename if wildcards are allowed */if (WildCardsPermissible && (FirstPart.Length == 1 || FirstPart.Length == 2) && FirstPart.Buffer[0] == '.')
{
if (FirstPart.Length == 2)
{
if (FirstPart.Buffer[1] == '.')
{
goto EndLoop;
}
}
else
{
goto EndLoop;
}
}
/* Filename must be 255 bytes maximum */if (FirstPart.Length > 255)
returnFALSE;
/* Now, we will parse the filename to find everything bad in */for (i = 0; i < FirstPart.Length; i++)
{
/* First make sure the character it's not the Lead DBCS */if (FsRtlIsLeadDbcsCharacter(FirstPart.Buffer[i]))
{
if (i == (FirstPart.Length) - 1)
returnFALSE;
i++;
}
/* Then check for bad characters */elseif (!FsRtlIsAnsiCharacterLegalHpfs(FirstPart.Buffer[i], WildCardsPermissible))
{
returnFALSE;
}
}
/* Filename mustn't finish with a space or a dot */if ((FirstPart.Buffer[FirstPart.Length - 1] == ' ') ||
(FirstPart.Buffer[FirstPart.Length - 1] == '.'))
returnFALSE;
EndLoop:
/* Preparing next loop */
Name.Buffer = RemainingPart.Buffer;
Name.Length = RemainingPart.Length;
Name.MaximumLength = RemainingPart.MaximumLength;
/* Call once again our dissect function */FsRtlDissectDbcs(Name, &FirstPart, &RemainingPart);
/* We found a pathname, it wasn't allowed */if (FirstPart.Length > 0 && !PathNamePermissible)
returnFALSE;
}
returnTRUE;
}
Generated on Sun May 27 2012 06:06:43 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.