[Box Backup-commit] COMMIT r1045 - in box/chris/general/lib: raidfile win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sun Oct 15 15:53:58 BST 2006


Author: chris
Date: 2006-10-15 15:53:58 +0100 (Sun, 15 Oct 2006)
New Revision: 1045

Modified:
   box/chris/general/lib/raidfile/RaidFileRead.cpp
   box/chris/general/lib/raidfile/RaidFileWrite.cpp
   box/chris/general/lib/win32/emu.h
Log:
Use #defines to replace POSIX functions with emulated ones on MinGW,
like we do on MSVC, since it's just more reliable.

Disable emulated fstat() in raidfile (and use the POSIX one) by undefining 
fstat, since it doesn't use the other emulated file handling functions, or 
need Unicode support.


Modified: box/chris/general/lib/raidfile/RaidFileRead.cpp
===================================================================
--- box/chris/general/lib/raidfile/RaidFileRead.cpp	2006-10-15 13:52:10 UTC (rev 1044)
+++ box/chris/general/lib/raidfile/RaidFileRead.cpp	2006-10-15 14:53:58 UTC (rev 1045)
@@ -44,6 +44,9 @@
 #define READ_NUMBER_DISCS_REQUIRED	3
 #define READV_MAX_BLOCKS			64
 
+// We want to use POSIX fstat() for now, not the emulated one
+#undef fstat
+
 // --------------------------------------------------------------------------
 //
 // Class

Modified: box/chris/general/lib/raidfile/RaidFileWrite.cpp
===================================================================
--- box/chris/general/lib/raidfile/RaidFileWrite.cpp	2006-10-15 13:52:10 UTC (rev 1044)
+++ box/chris/general/lib/raidfile/RaidFileWrite.cpp	2006-10-15 14:53:58 UTC (rev 1045)
@@ -35,6 +35,9 @@
 // Must have this number of discs in the set
 #define TRANSFORM_NUMBER_DISCS_REQUIRED	3
 
+// we want to use POSIX fstat() for now, not the emulated one
+#undef fstat
+
 // --------------------------------------------------------------------------
 //
 // Function

Modified: box/chris/general/lib/win32/emu.h
===================================================================
--- box/chris/general/lib/win32/emu.h	2006-10-15 13:52:10 UTC (rev 1044)
+++ box/chris/general/lib/win32/emu.h	2006-10-15 14:53:58 UTC (rev 1045)
@@ -141,41 +141,6 @@
 	return 0;
 }
 
-int   emu_chdir (const char* pDirName);
-int   emu_unlink(const char* pFileName);
-char* emu_getcwd(char* pBuffer, int BufSize);
-int   emu_utimes(const char* pName, const struct timeval[]);
-int   emu_chmod (const char* pName, mode_t mode);
-
-#define utimes(buffer, times) emu_utimes(buffer, times)
-
-#ifdef _MSC_VER
-	#define chmod(file, mode)     emu_chmod(file, mode)
-	#define chdir(directory)      emu_chdir(directory)
-	#define unlink(file)          emu_unlink(file)
-	#define getcwd(buffer, size)  emu_getcwd(buffer, size)
-#else
-	inline int chmod(const char * pName, mode_t mode)
-	{
-		return emu_chmod(pName, mode);
-	}
-
-	inline int chdir(const char* pDirName)
-	{
-		return emu_chdir(pDirName);
-	}
-
-	inline char* getcwd(char* pBuffer, int BufSize)
-	{
-		return emu_getcwd(pBuffer, BufSize);
-	}
-
-	inline int unlink(const char* pFileName)
-	{
-		return emu_unlink(pFileName);
-	}
-#endif
-
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
 #endif
@@ -213,13 +178,6 @@
 
 #define vsnprintf _vsnprintf
 
-int emu_mkdir(const char* pPathName);
-
-inline int mkdir(const char *pPathName, mode_t mode = 0)
-{
-	return emu_mkdir(pPathName);
-}
-
 #ifndef __MINGW32__
 inline int strcasecmp(const char *s1, const char *s2)
 {
@@ -329,33 +287,31 @@
 };
 #endif
 
-int emu_stat(const char * name, struct stat * st);
-int emu_fstat(HANDLE file, struct stat * st);
-int statfs(const char * name, struct statfs * s);
-
 // need this for conversions
 time_t ConvertFileTimeToTime_t(FILETIME *fileTime);
 bool   ConvertTime_tToFileTime(const time_t from, FILETIME *pTo);
 
-#ifdef _MSC_VER
-	#define stat(filename,  struct) emu_stat (filename, struct)
-	#define lstat(filename, struct) emu_stat (filename, struct)
-	#define fstat(handle,   struct) emu_fstat(handle,   struct)
-#else
-	inline int stat(const char* filename, struct stat* stat)
-	{
-		return emu_stat(filename, stat);
-	}
-	inline int lstat(const char* filename, struct stat* stat)
-	{
-		return emu_stat(filename, stat);
-	}
-	inline int fstat(HANDLE handle, struct stat* stat)
-	{
-		return emu_fstat(handle, stat);
-	}
-#endif
+int   emu_chdir  (const char* pDirName);
+int   emu_mkdir  (const char* pPathName);
+int   emu_unlink (const char* pFileName);
+int   emu_fstat  (HANDLE file,       struct stat* st);
+int   emu_stat   (const char* pName, struct stat* st);
+int   emu_utimes (const char* pName, const struct timeval[]);
+int   emu_chmod  (const char* pName, mode_t mode);
+char* emu_getcwd (char* pBuffer,     int BufSize);
 
+#define chdir(directory)        emu_chdir  (directory)
+#define mkdir(path,     mode)   emu_mkdir  (path)
+#define unlink(file)            emu_unlink (file)
+#define stat(filename,  struct) emu_stat   (filename, struct)
+#define lstat(filename, struct) emu_stat   (filename, struct)
+#define fstat(handle,   struct) emu_fstat  (handle,   struct)
+#define utimes(buffer,  times)  emu_utimes (buffer,   times)
+#define chmod(file,     mode)   emu_chmod  (file,     mode)
+#define getcwd(buffer,  size)   emu_getcwd (buffer,   size)
+
+int statfs(const char * name, struct statfs * s);
+
 int poll(struct pollfd *ufds, unsigned long nfds, int timeout);
 bool EnableBackupRights( void );
 




More information about the Boxbackup-commit mailing list