diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util.h | 4 | ||||
-rw-r--r-- | base/file_util_win.cc | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/base/file_util.h b/base/file_util.h index b060579..9624e60 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -208,6 +208,10 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, const wchar_t *working_dir, const wchar_t *arguments, const wchar_t *description, const wchar_t *icon, int icon_index); + +// Return true if the given directory is empty +bool IsDirectoryEmpty(const std::wstring& dir_path); + #endif diff --git a/base/file_util_win.cc b/base/file_util_win.cc index fc53dc9..8253e53 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -365,6 +365,13 @@ bool UpdateShortcutLink(const wchar_t *source, const wchar_t *destination, return SUCCEEDED(result); } +bool IsDirectoryEmpty(const std::wstring& dir_path) { + FileEnumerator files(dir_path, false, FileEnumerator::FILES_AND_DIRECTORIES); + if (files.Next().empty()) + return true; + return false; +} + bool GetTempDir(std::wstring* path) { wchar_t temp_path[MAX_PATH + 1]; DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); |