use statvfs() if statfs() is not available (Solaris)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-10-19 19:03:52 +00:00
parent 8461e4c253
commit 9952adac06
4 changed files with 236 additions and 916 deletions

1104
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -2723,11 +2723,12 @@ fi
dnl check for vfork() (even if it's the same as fork() in modern Unices) dnl check for vfork() (even if it's the same as fork() in modern Unices)
AC_CHECK_FUNCS(vfork) AC_CHECK_FUNCS(vfork)
dnl get the library function to use for wxGetDiskSpace() dnl get the library function to use for wxGetDiskSpace(): it is statfs() under
dnl Linux and *BSD and statvfs() under Solaris
AC_CACHE_CHECK(for statfs, wx_cv_func_statfs, AC_CACHE_CHECK(for statfs, wx_cv_func_statfs,
AC_TRY_COMPILE( AC_TRY_COMPILE(
[ [
#ifdef __BSD__ #if defined(__BSD__)
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
#else #else
@@ -2754,7 +2755,33 @@ AC_CACHE_CHECK(for statfs, wx_cv_func_statfs,
if test "$wx_cv_func_statfs" = "yes"; then if test "$wx_cv_func_statfs" = "yes"; then
AC_DEFINE(HAVE_STATFS) AC_DEFINE(HAVE_STATFS)
else else
AC_MSG_WARN([wxGetDiskSpace() function won't work without statfs()]) AC_CACHE_CHECK(for statvfs, wx_cv_func_statvfs,
AC_TRY_COMPILE(
[
#include <sys/statvfs.h>
],
[
long l;
struct statvfs fs;
statvfs("/", &fs);
l = fs.f_bsize;
l += fs.f_blocks;
l += fs.f_bavail;
],
[
wx_cv_func_statvfs=yes
],
[
wx_cv_func_statvfs=no
]
)
]
if test "$wx_cv_func_statvfs" = "yes"; then
AC_DEFINE(HAVE_STATVFS)
else
AC_MSG_WARN([wxGetDiskSpace() function won't work without statfs()])
fi
fi fi
dnl check for fcntl() or at least flock() needed by Unix implementation of dnl check for fcntl() or at least flock() needed by Unix implementation of

View File

@@ -874,6 +874,9 @@
/* define if you have statfs function */ /* define if you have statfs function */
#undef HAVE_STATFS #undef HAVE_STATFS
/* define if you have statvfs function */
#undef HAVE_STATVFS
/* Define if you have strptime() */ /* Define if you have strptime() */
#undef HAVE_STRPTIME #undef HAVE_STRPTIME

View File

@@ -37,6 +37,12 @@
# endif # endif
#endif // HAVE_STATFS #endif // HAVE_STATFS
#ifdef HAVE_STATVFS
#include <sys/statvfs.h>
#define statfs statvfs
#endif // HAVE_STATVFS
#if wxUSE_GUI #if wxUSE_GUI
#include "wx/unix/execute.h" #include "wx/unix/execute.h"
#endif #endif
@@ -1008,8 +1014,7 @@ long wxGetFreeMemory()
#ifndef __WXMAC__ #ifndef __WXMAC__
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
{ {
#ifdef HAVE_STATFS #if defined(HAVE_STATFS) || defined(HAVE_STATVFS)
struct statfs fs; struct statfs fs;
if ( statfs(path, &fs) != 0 ) if ( statfs(path, &fs) != 0 )
{ {
@@ -1018,6 +1023,9 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
return FALSE; return FALSE;
} }
// under Solaris we might have to use fs.f_frsize instead as I think it
// may be a multiple of the block size in general (TODO)
if ( pTotal ) if ( pTotal )
{ {
*pTotal = wxLongLong(fs.f_blocks) * fs.f_bsize; *pTotal = wxLongLong(fs.f_blocks) * fs.f_bsize;