added wxGetDiskSpace for Win/Unix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -28,6 +28,10 @@
|
||||
|
||||
#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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user