aboutsummaryrefslogtreecommitdiff
path: root/libbutl/filesystem.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'libbutl/filesystem.ixx')
-rw-r--r--libbutl/filesystem.ixx16
1 files changed, 16 insertions, 0 deletions
diff --git a/libbutl/filesystem.ixx b/libbutl/filesystem.ixx
index eb9984b..a6fae64 100644
--- a/libbutl/filesystem.ixx
+++ b/libbutl/filesystem.ixx
@@ -7,9 +7,25 @@ namespace butl
inline bool
dir_empty (const dir_path& d)
{
+ // @@ Could 0 size be a valid and faster way?
+ //
return dir_iterator (d) == dir_iterator ();
}
+ inline bool
+ file_empty (const path& f)
+ {
+ auto p (path_entry (f));
+
+ if (p.first && p.second.type == entry_type::regular)
+ return p.second.size == 0;
+
+ throw_generic_error (
+ p.first
+ ? (p.second.type == entry_type::directory ? EISDIR : EINVAL)
+ : ENOENT);
+ }
+
inline rmdir_status
try_rmdir_r (const dir_path& p, bool ignore_error)
{