Skip to content
Extraits de code Groupes Projets
Valider 231adad9 rédigé par Thomas Goyne's avatar Thomas Goyne
Parcourir les fichiers

Implement agi::util::freespace for Windows

Originally committed to SVN as r5497.
parent 6f22088b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -65,7 +65,7 @@ namespace agi { ...@@ -65,7 +65,7 @@ namespace agi {
/// Check for amount of free space on a Path. /// Check for amount of free space on a Path.
// @param path[in] Path to check // @param path[in] Path to check
// @param type PathType (default is TypeDir) // @param type PathType (default is TypeDir)
uint64_t freespace(std::string &path, PathType type=TypeDir); uint64_t freespace(std::string const& path, PathType type=TypeDir);
struct delete_ptr { struct delete_ptr {
template<class T> template<class T>
......
...@@ -66,7 +66,7 @@ void time_log(timeval &tv) { ...@@ -66,7 +66,7 @@ void time_log(timeval &tv) {
gettimeofday(&tv, (struct timezone *)NULL); gettimeofday(&tv, (struct timezone *)NULL);
} }
uint64_t freespace(std::string &path, PathType type) { uint64_t freespace(std::string const& path, PathType type) {
struct statvfs fs; struct statvfs fs;
std::string check(path); std::string check(path);
......
...@@ -111,5 +111,19 @@ void time_log(agi_timeval &tv) { ...@@ -111,5 +111,19 @@ void time_log(agi_timeval &tv) {
tv.tv_usec = (long)(tmpres % 1000000UL); tv.tv_usec = (long)(tmpres % 1000000UL);
} }
uint64_t freespace(std::string const& path, PathType type) {
if (type == TypeFile)
return freespace(DirName(path));
ULARGE_INTEGER bytes_available;
if (GetDiskFreeSpaceEx(ConvertW(path).c_str(), &bytes_available, 0, 0))
return bytes_available.QuadPart;
acs::CheckDirRead(path);
/// @todo GetLastError -> Exception mapping
throw "Unknown error getting free space";
}
} // namespace io } // namespace io
} // namespace agi } // namespace agi
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter