Bug 611934 - OS/2 - implement fallocate() and fix build break; r=taras a=bsmedberg
authorRich Walsh <rich@e-vertise.com>
Wed, 02 Feb 2011 13:51:22 -0500
changeset 61794 a548a19f34a291c13fc3714a07c10747f3566927
parent 61793 af87fa0a3052d6dd3ae3f5ce3d2f7b5ee64af3ef
child 61795 8df0d4bd765f2e5b601341a30f2158d97c867440
push idunknown
push userunknown
push dateunknown
reviewerstaras, bsmedberg
bugs611934
milestone2.0b12pre
Bug 611934 - OS/2 - implement fallocate() and fix build break; r=taras a=bsmedberg
xpcom/glue/FileUtils.cpp
xpcom/glue/FileUtils.h
--- a/xpcom/glue/FileUtils.cpp
+++ b/xpcom/glue/FileUtils.cpp
@@ -37,16 +37,19 @@
  * ***** END LICENSE BLOCK ***** */
 #if defined(XP_UNIX)
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #elif defined(XP_WIN)
 #include <windows.h>
+#elif defined(XP_OS2)
+#define INCL_DOSFILEMGR
+#include <os2.h>
 #endif
 
 #include "nscore.h"
 #include "private/pprio.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/FunctionTimer.h"
 
 bool 
@@ -62,16 +65,19 @@ mozilla::fallocate(PRFileDesc *aFD, PRIn
 
   if (PR_Seek64(aFD, aLength, PR_SEEK_SET) != aLength)
     return false;
 
   bool retval = (0 != SetEndOfFile((HANDLE)PR_FileDesc2NativeHandle(aFD)));
 
   PR_Seek64(aFD, oldpos, PR_SEEK_SET);
   return retval;
+#elif defined(XP_OS2)
+  return aLength <= PR_UINT32_MAX
+    && 0 == DosSetFileSize(PR_FileDesc2NativeHandle(aFD), (PRUint32)aLength);
 #elif defined(XP_MACOSX)
   int fd = PR_FileDesc2NativeHandle(aFD);
   fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, aLength};
   // Try to get a continous chunk of disk space
   int ret = fcntl(fd, F_PREALLOCATE, &store);
   if (-1 == ret) {
     // OK, perhaps we are too fragmented, allocate non-continuous
     store.fst_flags = F_ALLOCATEALL;
--- a/xpcom/glue/FileUtils.h
+++ b/xpcom/glue/FileUtils.h
@@ -35,17 +35,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_FileUtils_h
 #define mozilla_FileUtils_h
 
-#if defined(XP_UNIX)
+#if defined(XP_UNIX) || defined(XP_OS2)
 # include <unistd.h>
 #elif defined(XP_WIN)
 # include <io.h>
 #endif
 #include "prio.h"
 
 namespace mozilla {