]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/utilsunx.cpp
added error message in case older apple header files are used
[wxWidgets.git] / src / unix / utilsunx.cpp
index ad8a078fabd6c6d96e2bf1a4e514748e168e4634..3bd19ffbf6a38d18bd3c3ed5c44abebd7794f852 100644 (file)
 
 #include "wx/stream.h"
 
+#ifdef HAVE_STATFS
+    #include <sys/vfs.h>
+#endif // HAVE_STATFS
+
 #if wxUSE_GUI
     #include "wx/unix/execute.h"
 #endif
@@ -909,6 +913,34 @@ long wxGetFreeMemory()
     return -1;
 }
 
+bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
+{
+#ifdef HAVE_STATFS
+
+    struct statfs fs;
+    if ( statfs(path, &fs) != 0 )
+    {
+        wxLogSysError("Failed to get file system statistics");
+
+        return FALSE;
+    }
+
+    if ( pTotal )
+    {
+        *pTotal = wxLongLong(fs.f_blocks) * fs.f_bsize;
+    }
+
+    if ( pFree )
+    {
+        *pFree = wxLongLong(fs.f_bavail) * fs.f_bsize;
+    }
+
+    return TRUE;
+#endif // HAVE_STATFS
+
+    return FALSE;
+}
+
 // ----------------------------------------------------------------------------
 // env vars
 // ----------------------------------------------------------------------------