[UDFS]
[reactos.git] / reactos / drivers / filesystems / udfs / udf_info / udf_info.cpp
index 255bbd9..d7f9771 100644 (file)
@@ -1,6 +1,7 @@
 ////////////////////////////////////////////////////////////////////
 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
 // All rights reserved
+// This file was released under the GPLv2 on June 2015.
 ////////////////////////////////////////////////////////////////////
 /*
         Module name:
@@ -323,8 +324,7 @@ UDFReadFileEntry(
     return STATUS_SUCCESS;
 } // UDFReadFileEntry()
 
-//#ifndef _X86_
-#ifndef _MSC_VER
+#if !defined (_X86_) || !defined (_MSC_VER)
 /*
     Decides if a Unicode character matches one of a list
     of ASCII characters.
@@ -355,11 +355,15 @@ UDFUnicodeInString(
     Decides whether character passed is an illegal character for a
     DOS file name.
 */
+#ifdef _MSC_VER
 #pragma warning(push)               
 #pragma warning(disable:4035)               // re-enable below
+#endif
 
 #ifdef _X86_
+#ifdef _MSC_VER
 __declspec (naked)
+#endif
 #endif // _X86_
 BOOLEAN
 __fastcall
@@ -368,8 +372,7 @@ UDFIsIllegalChar(
     )
 {
     // Genuine illegal char's for DOS.
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
   _asm {
     push ebx
 
@@ -397,7 +400,9 @@ ERR_IIC2:
 #endif // _X86_
 } // end UDFIsIllegalChar()
 
+#ifdef _MSC_VER
 #pragma warning(pop)  // re-enable warning #4035
+#endif
 
 /*
     Translate udfName to dosName using OSTA compliant.
@@ -880,7 +885,7 @@ UDFDOSName201(
     /* If the name has illegal characters or and extension, it */
     /* is not a DOS device name. */
 
-/*    if (needsCRC == FALSE && extLen == 0) {
+/*    if (needsCRC == FALSE && extLen == 0) { */
         /* If this is the name of a DOS device, a CRC code should */
         /* be appended to the file name. 
         if (IsDeviceName(udfName, udfLen))
@@ -975,7 +980,7 @@ UDFBuildFileEntry(
 {
     PFILE_ENTRY FileEntry;
     OSSTATUS status;
-    EntityID* eID;
+//    EntityID* eID;
     uint32 l;
     EXTENT_INFO _FEExtInfo;
     uint16* lcp;
@@ -1020,11 +1025,11 @@ UDFBuildFileEntry(
     FileEntry->gid = Vcb->DefaultGID;
 
     if(Extended) {
-        eID = &(((PEXTENDED_FILE_ENTRY)FileEntry)->impIdent);
+//        eID = &(((PEXTENDED_FILE_ENTRY)FileEntry)->impIdent);
         lcp = &(((PEXTENDED_FILE_ENTRY)FileEntry)->fileLinkCount);
         ((PEXTENDED_FILE_ENTRY)FileEntry)->checkpoint = 1;
     } else {
-        eID = &(FileEntry->impIdent);
+//        eID = &(FileEntry->impIdent);
         lcp = &(FileEntry->fileLinkCount);
         ((PFILE_ENTRY)FileEntry)->checkpoint = 1;
     }
@@ -1522,7 +1527,7 @@ UDFChangeFileCounter(
     counter = FileCounter ?
         &(Vcb->numFiles) :
         &(Vcb->numDirs);
-    if(*counter == -1)
+    if(*counter == (ULONG)-1)
         return;
     if(Increase) {
         UDFInterlockedIncrement((int32*)counter);
@@ -1949,13 +1954,13 @@ UDFUnlinkAllFilesInDir(
 
     hCurDirNdx = DirInfo->Dloc->DirIndex;
     // check if we can delete all files
-    for(i=2; CurDirNdx = UDFDirIndex(hCurDirNdx,i); i++) {
+    for(i=2; (CurDirNdx = UDFDirIndex(hCurDirNdx,i)); i++) {
         // try to open Stream
         if(CurDirNdx->FileInfo)
             return STATUS_CANNOT_DELETE;
     }
     // start deletion
-    for(i=2; CurDirNdx = UDFDirIndex(hCurDirNdx,i); i++) {
+    for(i=2; (CurDirNdx = UDFDirIndex(hCurDirNdx,i)); i++) {
         // try to open Stream
         status = UDFOpenFile__(Vcb, FALSE, TRUE, NULL, DirInfo, &FileInfo, &i);
         if(status == STATUS_FILE_DELETED) {
@@ -2029,7 +2034,7 @@ UDFOpenFile__(
     // some routines may send invalid Index
     if(!(DirNdx = UDFDirIndex(hDirNdx,i)))
         return STATUS_OBJECT_NAME_NOT_FOUND;
-    if(FileInfo = DirNdx->FileInfo) {
+    if((FileInfo = DirNdx->FileInfo)) {
         // file is already opened.
         if((DirNdx->FileCharacteristics & FILE_DELETED) && NotDeleted) {
             AdPrint(("  FILE_DELETED on open\n"));
@@ -2306,7 +2311,7 @@ UDFCleanUpFile__(
 
     IsASDir = UDFIsAStreamDir(FileInfo);
 
-    if(Dloc = FileInfo->Dloc) {
+    if((Dloc = FileInfo->Dloc)) {
 
 #ifdef UDF_DBG
         DirInfo = FileInfo->ParentFile;
@@ -2348,7 +2353,7 @@ UDFCleanUpFile__(
 
         if(Dloc->DirIndex) {
             uint_di i;
-            for(i=2; DirNdx = UDFDirIndex(Dloc->DirIndex,i); i++) {
+            for(i=2; (DirNdx = UDFDirIndex(Dloc->DirIndex,i)); i++) {
                 if(DirNdx->FileInfo) {
                     if(!KeepDloc) {
                         BrutePoint();
@@ -2414,7 +2419,9 @@ UDFCleanUpFile__(
 
         if(!KeepDloc) {
 
+#ifdef UDF_DBG
             ASSERT(!Modified);
+#endif
 
 #ifndef UDF_TRACK_ONDISK_ALLOCATION
             if(Dloc->DataLoc.Mapping)  MyFreePool__(Dloc->DataLoc.Mapping);
@@ -2432,7 +2439,7 @@ UDFCleanUpFile__(
 #endif //UDF_TRACK_ONDISK_ALLOCATION
             if(FileInfo->Dloc->DirIndex) {
                 uint_di i;
-                for(i=2; DirNdx = UDFDirIndex(Dloc->DirIndex,i); i++) {
+                for(i=2; (DirNdx = UDFDirIndex(Dloc->DirIndex,i)); i++) {
                     ASSERT(!DirNdx->FileInfo);
                     if(DirNdx->FName.Buffer)
                         MyFreePool__(DirNdx->FName.Buffer);
@@ -2735,7 +2742,7 @@ CreateUndel:
 #endif // UDF_LIMIT_DIR_SIZE
             // search for suitable unused entry
             if(UDFDirIndexInitScan(DirInfo, &ScanContext, 2)) {
-                while(DirNdx = UDFDirIndexScan(&ScanContext, NULL)) {
+                while((DirNdx = UDFDirIndexScan(&ScanContext, NULL))) {
                     if((DirNdx->Length == l) && UDFIsDeleted(DirNdx) &&
                        !DirNdx->FileInfo ) {
                         // free unicode-buffer with old name
@@ -2772,7 +2779,7 @@ CreateUndel:
             DirNdx->Offset = 0;
         }
         // new terminator is recorded by UDFDirIndexGrow()
-        if( ((d = (LBS - (DirNdx->Offset + l + DirInfo->Dloc->DataLoc.Offset) & (LBS-1) )) < sizeof(FILE_IDENT_DESC)) &&
+        if( ((d = ((LBS - (DirNdx->Offset + l + DirInfo->Dloc->DataLoc.Offset)) & (LBS-1) )) < sizeof(FILE_IDENT_DESC)) &&
               d ) {
             // insufficient space at the end of last sector for
             // next FileIdent's tag. fill it with ImpUse data
@@ -4268,11 +4275,12 @@ UDFCompareFileInfo(
     This routine computes 32-bit hash based on CRC-32 from SSH
  */
 
+#ifdef _MSC_VER
 #pragma warning(push)               
 #pragma warning(disable:4035)               // re-enable below
+#endif
 
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 __declspec (naked)
 #endif // _X86_
 uint32 
@@ -4282,8 +4290,7 @@ crc32(
     IN uint32 len // EDX
     )
 {
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 //    uint32 _Size = len;
 
     __asm {
@@ -4339,8 +4346,7 @@ EO_CRC:
     The polynomial used is: x^16 + x^12 + x^15 + 1
 */
 
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 __declspec (naked)
 #endif // _X86_
 uint16 
@@ -4350,8 +4356,7 @@ UDFUnicodeCksum(
     uint32 n  // EDX
     )
 {
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 //    uint32 _Size = n;
 
     __asm {
@@ -4407,8 +4412,7 @@ EO_uCRC:
 #endif // _X86_
 } // end UDFUnicodeCksum()
 
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 __declspec (naked)
 #endif // _X86_
 uint16 
@@ -4418,8 +4422,7 @@ UDFUnicodeCksum150(
     uint32 n  // EDX
     )
 {
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 //    uint32 _Size = n;
 
     __asm {
@@ -4514,8 +4517,7 @@ use16_2:
     The OSTA-UDF(tm) 1.50 standard states that using CRCs is mandatory.
     The polynomial used is: x^16 + x^12 + x^15 + 1
 */
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 __declspec (naked)
 #endif // _X86_
 uint16 
@@ -4525,8 +4527,7 @@ UDFCrc(
     IN uint32 Size  // EDX
     )
 {
-//#ifdef _X86_
-#ifdef _MSC_VER
+#if defined (_X86_) && defined (_MSC_VER)
 //    uint32 _Size = Size;
 
     __asm {
@@ -4572,7 +4573,9 @@ EO_CRC:
 
 } // end UDFCrc()
 
+#ifdef _MSC_VER
 #pragma warning(pop)    // re-enable warning #4035
+#endif
 
 /*
     Read the first block of a tagged descriptor & check it.