]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/stat.h
Use nullptr instead of 0 for pointers
[libs/core.git] / source / fs / stat.h
index 0d5f6de184b6f7a725e648119172573125799375..c32e8798162787b40b47a4ff41d9c7603689e806 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MSP_FS_STAT_H_
 #define MSP_FS_STAT_H_
 
+#include <cstdint>
 #include <string>
 #include <msp/time/timestamp.h>
 #include "path.h"
@@ -16,11 +17,7 @@ enum FileType
        SYMLINK
 };
 
-#ifdef MSVC
-typedef __uint64 FileSize;
-#else
-typedef unsigned long long FileSize;
-#endif
+typedef uint64_t FileSize;
 
 /**
 Holds file information.
@@ -30,15 +27,26 @@ class Stat
 private:
        struct Private;
 
-       FileType type;
-       FileSize size;
-       FileSize alloc_size;
+       struct OwnerInfo
+       {
+               std::string owner;
+               std::string group;
+       };
+
+       bool exists = false;
+       FileType type = UNKNOWN;
+       FileSize size = 0;
+       FileSize alloc_size = 0;
        Time::TimeStamp mtime;
-       std::string owner;
-       std::string group;
+       mutable OwnerInfo owner_info;
+       Private *priv = nullptr;
 
-       Stat();
 public:
+       Stat() = default;
+       Stat(const Stat &);
+       Stat &operator=(const Stat &);
+       ~Stat();
+
        FileType get_type() const { return type; }
        bool is_regular() const { return type==REGULAR; }
        bool is_directory() const { return type==DIRECTORY; }
@@ -46,8 +54,10 @@ public:
        FileSize get_size() const { return size; }
        FileSize get_alloc_size() const { return alloc_size; }
        const Time::TimeStamp &get_modify_time() const { return mtime; }
-       const std::string &get_owner() const { return owner; }
-       const std::string &get_group() const { return group; }
+       const std::string &get_owner() const;
+       const std::string &get_group() const;
+
+       operator bool() const { return exists; }
 
        /// Returns a Stat object describing a file.
        static Stat stat(const Path &);