// headers
// ----------------------------------------------------------------------------
-#include <pwd.h>
-
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/wfstream.h"
#include "wx/unix/execute.h"
+#include "wx/unix/private.h"
+
+#include <pwd.h>
#if wxUSE_STREAMS
#endif // __BSD__/!__BSD__
#define wxStatfs statfs
+
+ #ifndef HAVE_STATFS_DECL
+ // some systems lack statfs() prototype in the system headers (AIX 4)
+ extern "C" int statfs(const char *path, struct statfs *buf);
+ #endif
#endif // HAVE_STATFS
#ifdef HAVE_STATVFS
#include <sys/utsname.h> // for uname()
#endif // HAVE_UNAME
+// Used by wxGetFreeMemory().
+#ifdef __SGI__
+ #include <sys/sysmp.h>
+ #include <sys/sysinfo.h> // for SAGET and MINFO structures
+#endif
+
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
#define WXEXECUTE_NARGS 127
+#if defined(__DARWIN__)
+long wxMacExecute(wxChar **argv,
+ int flags,
+ wxProcess *process);
+#endif
+
long wxExecute( const wxString& command, int flags, wxProcess *process )
{
wxCHECK_MSG( !command.empty(), 0, wxT("can't exec empty command") );
+ wxLogDebug(wxString(wxT("Launching: ")) + command);
#if wxUSE_THREADS
// fork() doesn't mix well with POSIX threads: on many systems the program
} while(*cptr);
argv[argc] = NULL;
+ long lRc;
+#if defined(__DARWIN__)
+ // wxMacExecute only executes app bundles.
+ // It returns an error code if the target is not an app bundle, thus falling
+ // through to the regular wxExecute for non app bundles.
+ lRc = wxMacExecute(argv, flags, process);
+ if( lRc != ((flags & wxEXEC_SYNC) ? -1 : 0))
+ return lRc;
+#endif
+
// do execute the command
- long lRc = wxExecute(argv, flags, process);
+ lRc = wxExecute(argv, flags, process);
// clean up
argc = 0;
const int fd = m_file->fd();
fd_set readfds;
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
+
+ wxFD_ZERO(&readfds);
+ wxFD_SET(fd, &readfds);
+
switch ( select(fd + 1, &readfds, NULL, NULL, &tv) )
{
case -1:
// wxExecute: the real worker function
// ----------------------------------------------------------------------------
-#ifdef __VMS
- #pragma message disable codeunreachable
-#endif
-
-long wxExecute(wxChar **argv,
- int flags,
- wxProcess *process)
+long wxExecute(wxChar **argv, int flags, wxProcess *process)
{
// for the sync execution, we return -1 to indicate failure, but for async
// case we return 0 which is never a valid PID
return traits->WaitForChild(execData);
}
+#if !defined(__VMS) && !defined(__INTEL_COMPILER)
return ERROR_RETURN_CODE;
-}
-
-#ifdef __VMS
- #pragma message enable codeunreachable
#endif
+}
#undef ERROR_RETURN_CODE
#undef ARGS_CLEANUP
}
#elif defined(__SUN__) && defined(_SC_AVPHYS_PAGES)
return (wxMemorySize)(sysconf(_SC_AVPHYS_PAGES)*sysconf(_SC_PAGESIZE));
+#elif defined(__SGI__)
+ struct rminfo realmem;
+ if ( sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0 )
+ return ((wxMemorySize)realmem.physmem * sysconf(_SC_PAGESIZE));
//#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably
#endif
return -1;
}
-bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
+bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
{
#if defined(HAVE_STATFS) || defined(HAVE_STATVFS)
// the case to "char *" is needed for AIX 4.3
// under Solaris we also have to use f_frsize field instead of f_bsize
// which is in general a multiple of f_frsize
#ifdef HAVE_STATVFS
- wxLongLong blockSize = fs.f_frsize;
+ wxDiskspaceSize_t blockSize = fs.f_frsize;
#else // HAVE_STATFS
- wxLongLong blockSize = fs.f_bsize;
+ wxDiskspaceSize_t blockSize = fs.f_bsize;
#endif // HAVE_STATVFS/HAVE_STATFS
if ( pTotal )
{
- *pTotal = wxLongLong(fs.f_blocks) * blockSize;
+ *pTotal = wxDiskspaceSize_t(fs.f_blocks) * blockSize;
}
if ( pFree )
{
- *pFree = wxLongLong(fs.f_bavail) * blockSize;
+ *pFree = wxDiskspaceSize_t(fs.f_bavail) * blockSize;
}
return true;
#endif // wxUSE_ON_FATAL_EXCEPTION
-// ----------------------------------------------------------------------------
-// error and debug output routines (deprecated, use wxLog)
-// ----------------------------------------------------------------------------
-
-#if WXWIN_COMPATIBILITY_2_2
-
-void wxDebugMsg( const char *format, ... )
-{
- va_list ap;
- va_start( ap, format );
- vfprintf( stderr, format, ap );
- fflush( stderr );
- va_end(ap);
-}
-
-void wxError( const wxString &msg, const wxString &title )
-{
- wxFprintf( stderr, _("Error ") );
- if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) );
- if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) );
- wxFprintf( stderr, wxT(".\n") );
-}
-
-void wxFatalError( const wxString &msg, const wxString &title )
-{
- wxFprintf( stderr, _("Error ") );
- if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) );
- if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) );
- wxFprintf( stderr, wxT(".\n") );
- exit(3); // the same exit code as for abort()
-}
-
-#endif // WXWIN_COMPATIBILITY_2_2
-
#endif // wxUSE_BASE
#if wxUSE_GUI