diff --git a/aegisub/libaegisub/common/util.cpp b/aegisub/libaegisub/common/util.cpp index 513e0ab2e5687782537ae4e88ad2c6f0fdfa06ab..52b76220f1bd301cb5a09d39b96244ab0d979168 100644 --- a/aegisub/libaegisub/common/util.cpp +++ b/aegisub/libaegisub/common/util.cpp @@ -38,8 +38,9 @@ namespace agi { void str_lower(std::string &str) { + std::locale loc; for (size_t i=0; i < str.length(); ++i) { - str[i] = std::tolower(str[i]); + str[i] = std::tolower(str[i], loc); } } @@ -54,23 +55,5 @@ int strtoi(std::string &str) { } -uint64_t freespace(std::string &path, PathType type) { - struct statfs fs; - std::string check(path); - - if (type == TypeFile) - check.assign(DirName(path)); - - acs::CheckDirRead(check); - - if ((statfs(check.c_str(), &fs)) == 0) { - return fs.f_bsize * fs.f_bavail; - } else { - /// @todo We need a collective set of exceptions for ENOTDIR, EIO etc. - throw("Failed getting free space"); - } -} - - } // namespace util } // namespace agi diff --git a/aegisub/libaegisub/lagi_pre.h b/aegisub/libaegisub/lagi_pre.h index ee51e5e7d9bcd2b6397ee4d7edc7499e27cca27d..164d61f37bbb246774b2dd0e0bb68380a85d4902 100644 --- a/aegisub/libaegisub/lagi_pre.h +++ b/aegisub/libaegisub/lagi_pre.h @@ -11,7 +11,6 @@ #include <string.h> #include <sys/stat.h> #include <sys/param.h> -#include <sys/mount.h> #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #else @@ -25,6 +24,11 @@ #include <io.h> #endif +// Unix C +#ifndef _WIN32 +# include <sys/mount.h> // yep, this exists on MacOS X as well, but not on Windows. +#endif + // Common C++ #include <deque> #include <climits> diff --git a/aegisub/libaegisub/unix/util.cpp b/aegisub/libaegisub/unix/util.cpp index 58845ff596ac4c97fd8982fc93618b82a55c6c79..ecc8bb2892c914b9ff2461227699d812b824b133 100644 --- a/aegisub/libaegisub/unix/util.cpp +++ b/aegisub/libaegisub/unix/util.cpp @@ -59,5 +59,23 @@ void time_log(timeval &tv) { gettimeofday(&tv, (struct timezone *)NULL); } +uint64_t freespace(std::string &path, PathType type) { + struct statfs fs; + std::string check(path); + + if (type == TypeFile) + check.assign(DirName(path)); + + acs::CheckDirRead(check); + + if ((statfs(check.c_str(), &fs)) == 0) { + return fs.f_bsize * fs.f_bavail; + } else { + /// @todo We need a collective set of exceptions for ENOTDIR, EIO etc. + throw("Failed getting free space"); + } +} + + } // namespace io } // namespace agi