X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fstat.h;h=fd6a2f75ba6092e7f72181b95b7c8fb332428fe8;hp=6ae551fd13836955bbd6a11f347a2b236abe0022;hb=HEAD;hpb=5a006c4fce0893b63f881a6c9ecd010f15770428 diff --git a/source/fs/stat.h b/source/fs/stat.h index 6ae551f..fd6a2f7 100644 --- a/source/fs/stat.h +++ b/source/fs/stat.h @@ -1,7 +1,9 @@ #ifndef MSP_FS_STAT_H_ #define MSP_FS_STAT_H_ +#include #include +#include #include #include "path.h" @@ -16,30 +18,35 @@ enum FileType SYMLINK }; -#ifdef MSVC -typedef __uint64 FileSize; -#else -typedef unsigned long long FileSize; -#endif +typedef uint64_t FileSize; /** Holds file information. */ -class Stat +class MSPCORE_API Stat { private: struct Private; - bool exists; - 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; public: - Stat(); + Stat() = default; + Stat(const Stat &); + Stat &operator=(const Stat &); + ~Stat(); FileType get_type() const { return type; } bool is_regular() const { return type==REGULAR; } @@ -48,8 +55,8 @@ 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; } @@ -67,7 +74,7 @@ inline Stat lstat(const Path &path) { return Stat::lstat(path); } /// Tests for existence of a file -bool exists(const Path &path); +MSPCORE_API bool exists(const Path &path); /// Tests whether a path refers to an existing regular file inline bool is_reg(const Path &path)