mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-06-04 06:05:00 -06:00
fileUtil: Add IsEmptyDir function
This commit is contained in:
parent
4e6ff317dd
commit
3a857f633f
@ -155,6 +155,24 @@ static void StripTailDirSlashes(std::string& fname) {
|
|||||||
fname.resize(i);
|
fname.resize(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsEmptyDir(const std::string& folder_path) {
|
||||||
|
if (!IsDirectory(folder_path)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool has_entries = false;
|
||||||
|
|
||||||
|
ForeachDirectoryEntry(nullptr, folder_path,
|
||||||
|
[&has_entries]([[maybe_unused]] u64* num_entries_out,
|
||||||
|
[[maybe_unused]] const std::string& directory,
|
||||||
|
[[maybe_unused]] const std::string& virtual_name) -> bool {
|
||||||
|
has_entries = true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return !has_entries;
|
||||||
|
}
|
||||||
|
|
||||||
bool Exists(const std::string& filename) {
|
bool Exists(const std::string& filename) {
|
||||||
std::string copy(filename);
|
std::string copy(filename);
|
||||||
StripTailDirSlashes(copy);
|
StripTailDirSlashes(copy);
|
||||||
|
|||||||
@ -121,6 +121,9 @@ private:
|
|||||||
friend class boost::serialization::access;
|
friend class boost::serialization::access;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if a folder is empty
|
||||||
|
[[nodiscard]] bool IsEmptyDir(const std::string& folder_path);
|
||||||
|
|
||||||
// Returns true if file filename exists
|
// Returns true if file filename exists
|
||||||
[[nodiscard]] bool Exists(const std::string& filename);
|
[[nodiscard]] bool Exists(const std::string& filename);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user