Rename get_dir_size() to get_dir_count()
[libi2ncommon] / src / filefunc.hxx
index a2f4bc0..6051707 100644 (file)
@@ -28,6 +28,12 @@ on this file might be covered by the GNU General Public License.
 #include "userfunc.hpp"
 #include <set>
 
+// make sure we have proper large file support
+#include <features.h>
+#ifndef _GNU_SOURCE
+    #define _GNU_SOURCE
+#endif
+
 namespace I2n
 {
 /**
@@ -61,6 +67,9 @@ public:
    time_t  mtime() const { return Mtime; }
    time_t  ctime() const { return Ctime; }
 
+   // bytes used on disk, calculated from allocated blocks
+   long long bytes_on_disk() const { return BytesOnDisk; }
+
    nlink_t num_hard_links() const { return NumLinks; }
    dev_t   device_type() const { return DeviceType; }
    time_t  last_modified_time() const { return Mtime; }
@@ -125,6 +134,7 @@ protected:
    gid_t   Gid;
    dev_t   DeviceType;
    off_t   Size;
+   long long BytesOnDisk;
    time_t  Atime;
    time_t  Mtime;
    time_t  Ctime;
@@ -152,6 +162,7 @@ time_t file_mtime(const std::string& path);
 
 bool get_dir(const std::string& path, std::vector< std::string >& result, bool include_dot_names= false );
 std::vector< std::string > get_dir(const std::string& path, bool include_dot_names= false );
+int get_dir_count(const std::string& path, bool include_dot_names= false );
 
 bool unlink(const std::string& path);
 
@@ -182,6 +193,8 @@ bool recursive_delete(const std::string &path,
                       std::string *error=NULL);
 
 std::string mkdtemp(const std::string &path_template, std::string *error=NULL);
+// mkstemp: see tmpfstream
+
 bool mkdir(const std::string &path, const mode_t &mode=0700, std::string *error=NULL);
 bool rmdir(const std::string &path, std::string *error=NULL);
 
@@ -190,6 +203,8 @@ bool chdir(const std::string &path, std::string *error=NULL);
 
 mode_t umask(mode_t mask);
 
+long long get_free_diskspace(const std::string& path);
+long long du(const std::string &path, std::string *error=NULL);
 
 /*
 ** more specialized tool function(s)