[CDFS]
[reactos.git] / reactos / drivers / filesystems / cdfs / fcb.c
index 6657008..1bd06c1 100644 (file)
@@ -73,17 +73,19 @@ CdfsCreateFCB(PCWSTR FileName)
     if(!Fcb) return NULL;
 
     RtlZeroMemory(Fcb, sizeof(FCB));
+    Fcb->PathName.Buffer = Fcb->PathNameBuffer;
+    Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
 
     if (FileName)
     {
-        CdfsWSubString(Fcb->PathName, FileName, sizeof(Fcb->PathName) / sizeof(Fcb->PathName[0]) - 1);
-        if (wcsrchr(Fcb->PathName, '\\') != 0)
+        RtlAppendUnicodeToString(&Fcb->PathName, FileName);
+        if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
         {
-            Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
+            Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
         }
         else
         {
-            Fcb->ObjectName = Fcb->PathName;
+            Fcb->ObjectName = Fcb->PathName.Buffer;
         }
     }
 
@@ -129,7 +131,7 @@ CdfsFCBIsDirectory(PFCB Fcb)
 BOOLEAN
 CdfsFCBIsRoot(PFCB Fcb)
 {
-    return(wcscmp(Fcb->PathName, L"\\") == 0);
+    return (Fcb->PathName.Length = sizeof(WCHAR) && Fcb->PathName.Buffer[0] == L'\\');
 }
 
 
@@ -156,9 +158,9 @@ CdfsReleaseFCB(PDEVICE_EXTENSION Vcb,
 {
     KIRQL  oldIrql;
 
-    DPRINT("releasing FCB at %p: %S, refCount:%d\n",
+    DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
         Fcb,
-        Fcb->PathName,
+        &Fcb->PathName,
         Fcb->RefCount);
 
     KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
@@ -209,8 +211,8 @@ CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
     {
         Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
 
-        DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
-        if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
+        DPRINT("Comparing '%wZ' and '%wZ'\n", FileName, &Fcb->PathName);
+        if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
         {
             Fcb->RefCount++;
             KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
@@ -365,12 +367,12 @@ CdfsMakeFCBFromDirEntry(PVCB Vcb,
 
     /* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
     if ((LongName[0] != 0) &&
-        (wcslen(DirectoryFCB->PathName) + 1 + wcslen(LongName) + 1 > MAX_PATH))
+        ((DirectoryFCB->PathName.Length / sizeof(WCHAR)) + 1 + wcslen(LongName) + 1 > MAX_PATH))
     {
         return(STATUS_OBJECT_NAME_INVALID);
     }
 
-    wcscpy(pathName, DirectoryFCB->PathName);
+    wcscpy(pathName, DirectoryFCB->PathName.Buffer);
     if (!CdfsFCBIsRoot(DirectoryFCB))
     {
         wcscat(pathName, L"\\");
@@ -488,7 +490,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
         DeviceExt,
         DirectoryFcb,
         FileToFind);
-    DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
+    DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
 
     /* default to '.' if no filename specified */
     if (FileToFind->Length == 0)