[fastfat_new]

- Add two names to an FCB - a short name, and a long name.
- Start implementing FatSetFcbNames, currently deals with short names only.
- Implement Fati8dot3ToString, with most of the code actually #if0ed, because FullFAT already does this conversion.

svn path=/trunk/; revision=43343
This commit is contained in:
Aleksey Bragin 2009-10-09 14:20:33 +00:00
parent 415b1f1591
commit d64568f5ff
4 changed files with 131 additions and 9 deletions

View file

@ -71,9 +71,9 @@ FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
Dcb->FullFileName.Length = 1 * sizeof(WCHAR);
Dcb->FullFileName.MaximumLength = 2 * sizeof(WCHAR);
Dcb->FileName.Name.Ansi.Buffer = "\\";
Dcb->FileName.Name.Ansi.Length = 1;
Dcb->FileName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR);
Dcb->ShortName.Name.Ansi.Buffer = "\\";
Dcb->ShortName.Name.Ansi.Length = 1;
Dcb->ShortName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR);
/* Fill dirent attribute byte copy */
Dcb->DirentFatFlags = FILE_ATTRIBUTE_DIRECTORY;

View file

@ -306,8 +306,14 @@ FatSetFullNameInFcb(PFCB Fcb,
VOID NTAPI
FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
IN PUNICODE_STRING Lfn,
IN PFCB Fcb);
VOID NTAPI
Fati8dot3ToString(IN PCHAR FileName,
IN BOOLEAN DownCase,
OUT POEM_STRING OutString);
/* ------------------------------------------------------------ rw.c */
NTSTATUS NTAPI

View file

@ -269,10 +269,11 @@ typedef struct _FCB
/* Mcb mapping Vbo->Lbo */
LARGE_MCB Mcb;
ULONG FirstCluster;
/* Links into FCB Trie */
FCB_NAME_LINK FileName;
/* Links into FCB Tree */
FCB_NAME_LINK ShortName;
FCB_NAME_LINK LongName;
/* Buffer for the short name */
WCHAR ShortNameBuffer[0xc];
CHAR ShortNameBuffer[0xc];
/* Full file name */
UNICODE_STRING FullFileName;
/* Long name with exact case */

View file

@ -150,7 +150,7 @@ FatCreateFcb(IN PFAT_IRP_CONTEXT IrpContext,
Fcb->FatHandle = FileHandle;
/* Set names */
FatSetFcbNames(IrpContext, Fcb);
FatSetFcbNames(IrpContext, NULL, Fcb);
return Fcb;
}
@ -247,10 +247,125 @@ FatSetFullNameInFcb(PFCB Fcb,
VOID
NTAPI
FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
IN PUNICODE_STRING Lfn,
IN PFCB Fcb)
{
// Set the short name first
UNIMPLEMENTED;
FF_DIRENT DirEnt;
FF_ERROR Err;
POEM_STRING ShortName;
/* Get the dir entry */
Err = FF_GetEntry(Fcb->Vcb->Ioman,
Fcb->FatHandle->DirEntry,
Fcb->FatHandle->DirCluster,
&DirEnt);
if (Err != FF_ERR_NONE)
{
DPRINT1("Error %d getting dirent of a file\n", Err);
return;
}
/* Initialize short name string */
ShortName = &Fcb->ShortName.Name.Ansi;
ShortName->Buffer = Fcb->ShortNameBuffer;
ShortName->Length = 0;
ShortName->MaximumLength = sizeof(Fcb->ShortNameBuffer);
/* Convert dirent to the proper string */
Fati8dot3ToString(DirEnt.FileName, FALSE, ShortName);
// Unicode name
// Add names to the splay tree
}
VOID
NTAPI
Fati8dot3ToString(IN PCHAR FileName,
IN BOOLEAN DownCase,
OUT POEM_STRING OutString)
{
#if 0
ULONG BaseLen, ExtLen;
CHAR *cString = OutString->Buffer;
ULONG i;
/* Calc base and ext lens */
for (BaseLen = 8; BaseLen > 0; BaseLen--)
{
if (FileName[BaseLen - 1] != ' ') break;
}
for (ExtLen = 3; ExtLen > 0; ExtLen--)
{
if (FileName[8 + ExtLen - 1] != ' ') break;
}
/* Process base name */
if (BaseLen)
{
RtlCopyMemory(cString, FileName, BaseLen);
/* Substitute the e5 thing */
if (cString[0] == 0x05) cString[0] = 0xe5;
/* Downcase if asked to */
if (DownCase)
{
/* Do it manually */
for (i = 0; i < BaseLen; i++)
{
if (cString[i] >= 'A' &&
cString[i] <= 'Z')
{
/* Lowercase it */
cString[i] += 'a' - 'A';
}
}
}
}
/* Process extension */
if (ExtLen)
{
/* Add the dot */
cString[BaseLen] = '.';
BaseLen++;
/* Copy the extension */
for (i = 0; i < ExtLen; i++)
{
cString[BaseLen + i] = FileName[8 + i];
}
/* Lowercase the extension if asked to */
if (DownCase)
{
/* Do it manually */
for (i = BaseLen; i < BaseLen + ExtLen; i++)
{
if (cString[i] >= 'A' &&
cString[i] <= 'Z')
{
/* Lowercase it */
cString[i] += 'a' - 'A';
}
}
}
}
/* Set the length */
OutString->Length = BaseLen + ExtLen;
#else
RtlCopyMemory(OutString->Buffer, FileName, 11);
OutString->Length = strlen(FileName);
ASSERT(OutString->Length <= 12);
#endif
DPRINT1("'%s', len %d\n", OutString->Buffer, OutString->Length);
}
/* EOF */