ecere/sys: Support for 64 bit reporting of available space
authorJerome St-Louis <jerome@ecere.com>
Wed, 7 Mar 2012 11:56:50 +0000 (06:56 -0500)
committerJerome St-Louis <jerome@ecere.com>
Wed, 7 Mar 2012 11:56:50 +0000 (06:56 -0500)
ecere/src/sys/File.ec
ecere/src/sys/System.c
ecere/src/sys/System.ec

index c647a16..0fa009d 100644 (file)
@@ -139,6 +139,43 @@ public class FileSize : uint
    }
 };
 
+public class FileSize64 : uint64
+{
+   int OnCompare(FileSize64 data2)
+   {
+      int result = 0;
+      if(&this && &data2)
+      {
+         if(this > data2)
+            result = 1;
+         else if(this < data2)
+            result = -1;
+      }
+      return result;
+   }
+
+   char * OnGetString(char * string, void * fieldData, bool * needClass)
+   {
+      PrintBigSize(string, this, 2);
+      return string;
+   }
+
+   bool OnGetDataFromString(char * string)
+   {
+      char * end;
+      double value = strtod(string, &end);
+      uint64 multiplier = 1;
+           if(strstr(end, "PB") || strstr(end, "pb")) multiplier = (uint64)1024 * 1024 * 1024 * 1024;
+      else if(strstr(end, "TB") || strstr(end, "tb")) multiplier = (uint64)1024 * 1024 * 1024 * 1024;
+      else if(strstr(end, "GB") || strstr(end, "gb")) multiplier = (uint64)1024 * 1024 * 1024;
+      else if(strstr(end, "MB") || strstr(end, "mb")) multiplier = (uint64)1024 * 1024;
+      else if(strstr(end, "KB") || strstr(end, "kb")) multiplier = 1024;
+
+      this = (uint64)(multiplier * value);
+      return true;
+   }
+};
+
 class FileSystem
 {
    virtual File ::Open(char * archive, char * name, FileOpenMode mode);
index 4eb4c3c..fa01fdf 100644 (file)
@@ -38,6 +38,7 @@ typedef unsigned int FileSize;
 typedef unsigned short uint16;
 typedef unsigned int uint;
 typedef unsigned long long uint64;
+typedef uint64 FileSize64;
 
 #define false 0
 #define true 1
@@ -391,7 +392,7 @@ bool System_ShellOpen(char * fileName, va_list args)
    return result;
 }
 
-void System_GetFreeSpace(char * path, FileSize * size)
+void System_GetFreeSpace(char * path, FileSize64 * size)
 {
    uint64 freeSize = 0;
 #ifdef __WIN32__
@@ -399,5 +400,5 @@ void System_GetFreeSpace(char * path, FileSize * size)
    GetDiskFreeSpaceEx(_wpath, (PULARGE_INTEGER)&freeSize, null, null);
    __ecereNameSpace__ecere__com__eSystem_Delete(_wpath);
 #endif
-   *size = (FileSize)freeSize;
+   *size = (FileSize64)freeSize;
 }
index 37b0020..04646e4 100644 (file)
@@ -44,7 +44,7 @@ void System_SetEnvironment(char * envName, char * envValue);
 void System_UnsetEnvironment(char * envName);
 bool System_Execute(char * env, char * command, va_list args);
 bool System_ShellOpen(char * fileName, va_list args);
-void System_GetFreeSpace(char * path, FileSize * size);
+void System_GetFreeSpace(char * path, FileSize64 * size);
 
 private:
 
@@ -194,7 +194,7 @@ public bool ShellOpen(char * fileName, ...)
    return result;
 }
 
-public void GetFreeSpace(char * path, FileSize * size)
+public void GetFreeSpace(char * path, FileSize64 * size)
 {
    System_GetFreeSpace(path, size);
 }