diff options
| author | msheby <msheby@cinecert.com> | 2009-04-08 17:41:37 +0000 |
|---|---|---|
| committer | msheby <> | 2009-04-08 17:41:37 +0000 |
| commit | 6e31ef7559099a10d42067fa57739b5e928d9277 (patch) | |
| tree | a6eca38ae5e5e12fea900dbeeba355b8328f0b44 /src/KM_fileio.cpp | |
| parent | 8d36841e7c881f0df67bf01021d02448fdde0d02 (diff) | |
Implement FreeSpaceForPath.
Diffstat (limited to 'src/KM_fileio.cpp')
| -rw-r--r-- | src/KM_fileio.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp index d5d5a40..9080631 100644 --- a/src/KM_fileio.cpp +++ b/src/KM_fileio.cpp @@ -1473,13 +1473,24 @@ Kumu::DeletePath(const std::string& pathname) // -#ifdef KM_WIN32 -#else // KM_WIN32 - -// Result_t Kumu::FreeSpaceForPath(const std::string& path, Kumu::fsize_t& free_space, Kumu::fsize_t& total_space) -{ +{
+#ifdef KM_WIN32 + ULARGE_INTEGER lTotalNumberOfBytes;
+ ULARGE_INTEGER lTotalNumberOfFreeBytes; + + BOOL fResult = ::GetDiskFreeSpaceEx(path.c_str(), NULL, &lTotalNumberOfBytes, &lTotalNumberOfFreeBytes); + if (fResult) {
+ free_space = static_cast<Kumu::fsize_t>(lTotalNumberOfFreeBytes.QuadPart); + total_space = static_cast<Kumu::fsize_t>(lTotalNumberOfBytes.QuadPart); + return RESULT_OK; + }
+ HRESULT LastError = ::GetLastError(); + + DefaultLogSink().Error("FreeSpaceForPath GetDiskFreeSpaceEx %s: %lu\n", path.c_str(), ::GetLastError()); + return RESULT_FAIL; +#else // KM_WIN32 struct statfs s; if ( statfs(path.c_str(), &s) == 0 ) @@ -1505,9 +1516,9 @@ Kumu::FreeSpaceForPath(const std::string& path, Kumu::fsize_t& free_space, Kumu: DefaultLogSink().Error("FreeSpaceForPath statfs %s: %s\n", path.c_str(), strerror(errno)); return RESULT_FAIL; +#endif // KM_WIN32 } -#endif // KM_WIN32 // // end KM_fileio.cpp |
