Fix building on newer Linux systems (particularly Fedora 13)
[reactos.git] / reactos / tools / cabman / cabinet.cxx
index c09eea9..5d834a9 100755 (executable)
 #include <string.h>
 #if !defined(WIN32)
 # include <dirent.h>
-#endif
-#if defined(__FreeBSD__) || defined(__APPLE__)
 # include <sys/stat.h>
-#endif // __FreeBSD__
+# include <sys/types.h>
+#endif
 #include "cabinet.h"
 #include "raw.h"
 #include "mszip.h"
@@ -64,7 +63,7 @@ static bool _ReadFileData(FILEHANDLE handle, void* buffer, ULONG size, PULONG by
 #ifndef CAB_READ_ONLY
 
 #if 0
-#ifdef DBG
+#if DBG
 
 void DumpBuffer(void* Buffer, ULONG Size)
 {
@@ -2055,9 +2054,19 @@ ULONG CCabinet::AddFile(char* FileName)
         return CAB_STATUS_CANNOT_READ;
     }
 
-    GetFileTimes(SrcFile, FileNode);
+    if (GetFileTimes(SrcFile, FileNode) != CAB_STATUS_SUCCESS)
+    {
+        DPRINT(MIN_TRACE, ("Cannot read file times.\n"));
+        FreeMemory(NewFileName);
+        return CAB_STATUS_CANNOT_READ;
+    }
 
-    GetAttributesOnFile(FileNode);
+    if (GetAttributesOnFile(FileNode) != CAB_STATUS_SUCCESS)
+    {
+        DPRINT(MIN_TRACE, ("Cannot read file attributes.\n"));
+        FreeMemory(NewFileName);
+        return CAB_STATUS_CANNOT_READ;
+    }
 
     CloseFile(SrcFile);
 
@@ -3646,7 +3655,8 @@ ULONG CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File)
         strcpy(buf, File->FileName);
     else
     {
-        getcwd(buf, sizeof(buf));
+        if (!getcwd(buf, sizeof(buf)))
+            return CAB_STATUS_CANNOT_READ;
         strcat(buf, DIR_SEPARATOR_STRING);
         strcat(buf, File->FileName);
     }
@@ -3689,7 +3699,8 @@ ULONG CCabinet::GetAttributesOnFile(PCFFILE_NODE File)
         strcpy(buf, File->FileName);
     else
     {
-        getcwd(buf, sizeof(buf));
+        if (!getcwd(buf, sizeof(buf)))
+            return CAB_STATUS_CANNOT_READ;
         strcat(buf, DIR_SEPARATOR_STRING);
         strcat(buf, File->FileName);
     }