[fastfat_new]
authorAleksey Bragin <aleksey@reactos.org>
Fri, 9 Oct 2009 14:20:33 +0000 (14:20 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Fri, 9 Oct 2009 14:20:33 +0000 (14:20 +0000)
- 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

reactos/drivers/filesystems/fastfat_new/dir.c
reactos/drivers/filesystems/fastfat_new/fastfat.h
reactos/drivers/filesystems/fastfat_new/fatstruc.h
reactos/drivers/filesystems/fastfat_new/fcb.c

index 0c3e8e7..abab230 100644 (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;
index cd1751c..d6be13f 100644 (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
index 103527b..51adee8 100644 (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 */
index d2961b7..7d48720 100644 (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 */