[FASTFAT] Don't add an extra \, when renaming a file at root.
[reactos.git] / drivers / filesystems / fastfat / finfo.c
index 2840b13..a19c21d 100644 (file)
@@ -787,8 +787,12 @@ VfatSetRenameInformation(
         }
 
         RtlCopyUnicodeString(&NewName, &((PVFATFCB)TargetFileObject->FsContext)->PathNameU);
-        NewName.Buffer[NewName.Length / sizeof(WCHAR)] = L'\\';
-        NewName.Length += sizeof(WCHAR);
+        /* If \, it's already backslash terminated, don't add it */
+        if (!vfatFCBIsRoot(TargetFileObject->FsContext))
+        {
+            NewName.Buffer[NewName.Length / sizeof(WCHAR)] = L'\\';
+            NewName.Length += sizeof(WCHAR);
+        }
         RtlAppendUnicodeStringToString(&NewName, &TargetFileObject->FileName);
     }
 
@@ -1344,8 +1348,6 @@ VfatSetAllocationSizeInformation(
     }
     else if (NewSize + ClusterSize <= Fcb->RFCB.AllocationSize.u.LowPart)
     {
-        ULONG ClusterCount;
-
         DPRINT("Check for the ability to set file size\n");
         if (!MmCanFileBeTruncated(FileObject->SectionObjectPointer,
                                   (PLARGE_INTEGER)AllocationSize))
@@ -1393,18 +1395,16 @@ VfatSetAllocationSizeInformation(
             Status = STATUS_SUCCESS;
         }
 
-        ClusterCount = 0;
         while (NT_SUCCESS(Status) && 0xffffffff != Cluster && Cluster > 1)
         {
             Status = NextCluster(DeviceExt, FirstCluster, &NCluster, FALSE);
             WriteCluster(DeviceExt, Cluster, 0);
             Cluster = NCluster;
-            ClusterCount++;
         }
 
-        if (ClusterCount != 0 && DeviceExt->FatInfo.FatType == FAT32)
+        if (DeviceExt->FatInfo.FatType == FAT32)
         {
-            FAT32UpdateFreeClustersCount(DeviceExt, ClusterCount, TRUE);
+            FAT32UpdateFreeClustersCount(DeviceExt);
         }
     }
     else