]> 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 23658ace65510ea4c523412dab259f6b4960474e..3bd19ffbf6a38d18bd3c3ed5c44abebd7794f852 100644 (file)
 
 #include "wx/stream.h"
 
 
 #include "wx/stream.h"
 
+#ifdef HAVE_STATFS
+    #include <sys/vfs.h>
+#endif // HAVE_STATFS
+
 #if wxUSE_GUI
     #include "wx/unix/execute.h"
 #endif
 #if wxUSE_GUI
     #include "wx/unix/execute.h"
 #endif
@@ -333,6 +337,8 @@ void wxHandleProcessTermination(wxEndProcessData *proc_data)
 // wxStream classes to support IO redirection in wxExecute
 // ----------------------------------------------------------------------------
 
 // wxStream classes to support IO redirection in wxExecute
 // ----------------------------------------------------------------------------
 
+#if wxUSE_STREAMS
+
 class wxProcessFileInputStream : public wxInputStream
 {
 public:
 class wxProcessFileInputStream : public wxInputStream
 {
 public:
@@ -429,6 +435,8 @@ size_t wxProcessFileOutputStream::OnSysWrite(const void *buffer, size_t bufsize)
     return ret;
 }
 
     return ret;
 }
 
+#endif // wxUSE_STREAMS
+
 long wxExecute(wxChar **argv,
                bool sync,
                wxProcess *process)
 long wxExecute(wxChar **argv,
                bool sync,
                wxProcess *process)
@@ -590,19 +598,21 @@ long wxExecute(wxChar **argv,
         // pipe initialization: construction of the wxStreams
         if ( process && process->IsRedirected() )
         {
         // pipe initialization: construction of the wxStreams
         if ( process && process->IsRedirected() )
         {
+#if wxUSE_STREAMS
             // These two streams are relative to this process.
             wxOutputStream *outStream = new wxProcessFileOutputStream(pipeIn[1]);
             wxInputStream *inStream = new wxProcessFileInputStream(pipeOut[0]);
             wxInputStream *errStream = new wxProcessFileInputStream(pipeErr[0]);
 
             // These two streams are relative to this process.
             wxOutputStream *outStream = new wxProcessFileOutputStream(pipeIn[1]);
             wxInputStream *inStream = new wxProcessFileInputStream(pipeOut[0]);
             wxInputStream *errStream = new wxProcessFileInputStream(pipeErr[0]);
 
+            process->SetPipeStreams(inStream, outStream, errStream);
+#endif // wxUSE_STREAMS
+
             close(pipeIn[0]); // close reading side
             close(pipeOut[1]); // close writing side
             close(pipeErr[1]); // close writing side
             close(pipeIn[0]); // close reading side
             close(pipeOut[1]); // close writing side
             close(pipeErr[1]); // close writing side
-
-            process->SetPipeStreams(inStream, outStream, errStream);
         }
 
         }
 
-#if wxUSE_GUI
+#if wxUSE_GUI && !defined(__WXMICROWIN__)
         wxEndProcessData *data = new wxEndProcessData;
 
         if ( sync )
         wxEndProcessData *data = new wxEndProcessData;
 
         if ( sync )
@@ -903,6 +913,34 @@ long wxGetFreeMemory()
     return -1;
 }
 
     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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // env vars
 // ----------------------------------------------------------------------------