summaryrefslogtreecommitdiff
path: root/src/KM_fileio.cpp
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2014-09-21 13:27:43 +0000
committerjhurst <>2014-09-21 13:27:43 +0000
commitab3e3df49a9d4a44a3bf11211e31bdeac3ef7bcf (patch)
tree52023c92807dde6cb56835e957349327f1b9df0b /src/KM_fileio.cpp
parent8d24b6effb0377fc3041c2e024e7c5593caecc52 (diff)
imf bugs
date parse bug timed-text transform removed
Diffstat (limited to 'src/KM_fileio.cpp')
-rw-r--r--src/KM_fileio.cpp43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index 417b17e..2b95d63 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -1657,6 +1657,31 @@ Kumu::DeletePath(const std::string& pathname)
}
+//
+Result_t
+Kumu::DeleteDirectoryIfEmpty(const std::string& path)
+{
+ DirScanner source_dir;
+ char next_file[Kumu::MaxFilePath];
+
+ Result_t result = source_dir.Open(path);
+
+ if ( KM_FAILURE(result) )
+ return result;
+
+ while ( KM_SUCCESS(source_dir.GetNext(next_file)) )
+ {
+ if ( ( next_file[0] == '.' && next_file[1] == 0 )
+ || ( next_file[0] == '.' && next_file[1] == '.' && next_file[2] == 0 ) )
+ continue;
+
+ return RESULT_NOT_EMPTY; // anything other than "." and ".." indicates a non-empty directory
+ }
+
+ return DeletePath(path);
+}
+
+
//------------------------------------------------------------------------------------------
//
@@ -1665,19 +1690,21 @@ 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;
+ ULARGE_INTEGER lTotalNumberOfBytes;
+ ULARGE_INTEGER lTotalNumberOfFreeBytes;
- BOOL fResult = ::GetDiskFreeSpaceExA(path.c_str(), NULL, &lTotalNumberOfBytes, &lTotalNumberOfFreeBytes);
- if (fResult) {
+ BOOL fResult = ::GetDiskFreeSpaceExA(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;
+ HRESULT last_error = ::GetLastError();
+
+ DefaultLogSink().Error("FreeSpaceForPath GetDiskFreeSpaceEx %s: %lu\n", path.c_str(), last_error);
+ return RESULT_FAIL;
#else // KM_WIN32
struct statfs s;