update for HEAD-2003091401
[reactos.git] / drivers / fs / vfat / dirwr.c
index 7f828f4..ec23e76 100644 (file)
@@ -42,8 +42,10 @@ VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
   PVFATFCB pDirFcb, pFcb;
   LARGE_INTEGER Offset;
 
+/*
   DPRINT ("updEntry PathFileName \'%S\'\n", 
           ((PVFATCCB)(pFileObject->FsContext2))->pFcb->PathName);
+*/
 
   pFcb = (PVFATFCB)pFileObject->FsContext;
   assert (pFcb);
@@ -144,8 +146,8 @@ findDirSpace(PDEVICE_EXTENSION DeviceExt,
         return FALSE;
       }
       // clear the new dir cluster
-      FileOffset.u.LowPart = pDirFcb->RFCB.FileSize.QuadPart -
-                               DeviceExt->FatInfo.BytesPerCluster;
+      FileOffset.u.LowPart = (DWORD)(pDirFcb->RFCB.FileSize.QuadPart -
+                                     DeviceExt->FatInfo.BytesPerCluster);
       CcMapData (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
                  TRUE, &Context, (PVOID*)&pFatEntry);
       RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
@@ -202,7 +204,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
   {
     if (PathFileName[i] == L'\\')
     {
-      posCar = i;
+      posCar = (short)i;
     }
   }
   if (posCar == -1)
@@ -243,7 +245,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
   {
     if (FileName[i] == '.')
     {
-      posCar = i;
+      posCar = (short)i;
       if (i == j)
       {
         j++;
@@ -252,11 +254,11 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
   }
   if (!posCar)
   {
-    posCar = i;
+    posCar = (short)i;
   }
   if (posCar < j)
   {
-    posCar = i;
+    posCar = (short)i;
     needTilde = TRUE;
   }
   if (posCar > 8)
@@ -332,8 +334,8 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
     //try first with xxxxxx~y.zzz
     for (i = 1; i < 10; i++)
     {
-      DirName[posCar-1] = '0' + i;
-      pEntry->Filename[posCar - 1] = '0' + i;
+      DirName[posCar-1] = (WCHAR)('0' + i);
+      pEntry->Filename[posCar - 1] = (unsigned char)('0' + i);
       Status = FindFile (DeviceExt, &FileFcb, pDirFcb, DirName, NULL, NULL);
       if (!NT_SUCCESS(Status))
       {
@@ -473,7 +475,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
   if (needLong)
   {
     // calculate checksum for 8.3 name
-    for (pSlots[0].alias_checksum = i = 0; i < 11; i++)
+    for (pSlots[0].alias_checksum = 0, i = 0; i < 11; i++)
     {
        pSlots[0].alias_checksum = (((pSlots[0].alias_checksum & 1) << 7
                                   | ((pSlots[0].alias_checksum & 0xfe) >> 1))
@@ -510,7 +512,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
   if (RequestedOptions & FILE_DIRECTORY_FILE)
   {
     CurrentCluster = 0xffffffff;
-    Status = NextCluster (DeviceExt, NULL, 0, &CurrentCluster, TRUE);
+    Status = NextCluster (DeviceExt, 0, &CurrentCluster, TRUE);
     if (CurrentCluster == 0xffffffff || !NT_SUCCESS(Status))
     {
       vfatReleaseFCB(DeviceExt, pDirFcb);
@@ -523,9 +525,9 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
     }
     if (DeviceExt->FatInfo.FatType == FAT32)
     {
-      pEntry->FirstClusterHigh = CurrentCluster >> 16;
+      pEntry->FirstClusterHigh = (unsigned short)(CurrentCluster >> 16);
     }
-    pEntry->FirstCluster = CurrentCluster;
+    pEntry->FirstCluster = (unsigned short)CurrentCluster;
   }
 
   size = DeviceExt->FatInfo.BytesPerCluster / sizeof(FATDirEntry);
@@ -554,7 +556,7 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
     CcMapData (pDirFcb->FileObject, &FileOffset,
                nbSlots * sizeof(FATDirEntry) - size,
                TRUE, &Context, (PVOID*)&pFatEntry);
-    memcpy(pFatEntry, (PVOID)Buffer + size, nbSlots * sizeof(FATDirEntry) - size);
+    memcpy(pFatEntry, (PVOID)(Buffer + size), nbSlots * sizeof(FATDirEntry) - size);
   }
   CcSetDirtyPinnedData(Context, NULL);
   CcUnpinData(Context);
@@ -616,8 +618,7 @@ delEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
   PVFATFCB pFcb = NULL, pDirFcb = NULL;
   NTSTATUS status;
   PWSTR pName;
-  ULONG Entry = 0, startEntry, Read, CurrentCluster, NextCluster, i;
-  FATDirEntry DirEntry;
+  ULONG Entry = 0, startEntry, CurrentCluster, NextCluster, i;
 
   DPRINT ("delEntry PathFileName \'%S\'\n", pFileObject->FileName.Buffer);