mirror of https://github.com/odrling/Aegisub
libaegisub: use statvfs instead of statfs
statvfs is the portable POSIX defined interface and is supported on all major UNIX platforms. Originally committed to SVN as r5367.
This commit is contained in:
parent
7db22972a7
commit
066ec3014a
|
@ -22,6 +22,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif // LAGI_PRE
|
#endif // LAGI_PRE
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
// Unix C
|
// Unix C
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <sys/mount.h> // yep, this exists on MacOS X as well, but not on Windows.
|
# include <sys/statvfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Common C++
|
// Common C++
|
||||||
|
|
|
@ -60,7 +60,7 @@ void time_log(timeval &tv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t freespace(std::string &path, PathType type) {
|
uint64_t freespace(std::string &path, PathType type) {
|
||||||
struct statfs fs;
|
struct statvfs fs;
|
||||||
std::string check(path);
|
std::string check(path);
|
||||||
|
|
||||||
if (type == TypeFile)
|
if (type == TypeFile)
|
||||||
|
@ -68,7 +68,7 @@ uint64_t freespace(std::string &path, PathType type) {
|
||||||
|
|
||||||
acs::CheckDirRead(check);
|
acs::CheckDirRead(check);
|
||||||
|
|
||||||
if ((statfs(check.c_str(), &fs)) == 0) {
|
if ((statvfs(check.c_str(), &fs)) == 0) {
|
||||||
return fs.f_bsize * fs.f_bavail;
|
return fs.f_bsize * fs.f_bavail;
|
||||||
} else {
|
} else {
|
||||||
/// @todo We need a collective set of exceptions for ENOTDIR, EIO etc.
|
/// @todo We need a collective set of exceptions for ENOTDIR, EIO etc.
|
||||||
|
|
Loading…
Reference in New Issue