diff --git a/aegisub/libaegisub/common/util.cpp b/aegisub/libaegisub/common/util.cpp index 513e0ab2e..52b76220f 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 ee51e5e7d..164d61f37 100644 --- a/aegisub/libaegisub/lagi_pre.h +++ b/aegisub/libaegisub/lagi_pre.h @@ -11,7 +11,6 @@ #include #include #include -#include #ifdef HAVE_SYS_TIME_H # include #else @@ -25,6 +24,11 @@ #include #endif +// Unix C +#ifndef _WIN32 +# include // yep, this exists on MacOS X as well, but not on Windows. +#endif + // Common C++ #include #include diff --git a/aegisub/libaegisub/unix/util.cpp b/aegisub/libaegisub/unix/util.cpp index 58845ff59..ecc8bb289 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