diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/fstat.h | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/fstat.h')
-rw-r--r-- | util/system/fstat.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/util/system/fstat.h b/util/system/fstat.h new file mode 100644 index 0000000000..64e79e1b55 --- /dev/null +++ b/util/system/fstat.h @@ -0,0 +1,47 @@ +#pragma once + +#include <util/generic/fwd.h> +#include <util/system/fhandle.h> + +class TFile; +class TFsPath; + +struct TFileStat { + ui32 Mode = 0; /* protection */ + ui32 Uid = 0; /* user ID of owner */ + ui32 Gid = 0; /* group ID of owner */ + + ui64 NLinks = 0; /* number of hard links */ + ui64 Size = 0; /* total size, in bytes */ + ui64 INode = 0; /* inode number */ + ui64 AllocationSize = 0; /* number of bytes allocated on the disk */ + + time_t ATime = 0; /* time of last access */ + time_t MTime = 0; /* time of last modification */ + time_t CTime = 0; /* time of last status change */ + +public: + TFileStat(); + + bool IsNull() const noexcept; + + bool IsFile() const noexcept; + bool IsDir() const noexcept; + bool IsSymlink() const noexcept; + + explicit TFileStat(const TFile& f); + explicit TFileStat(FHANDLE f); + TFileStat(const TFsPath& fileName, bool nofollow = false); + TFileStat(const TString& fileName, bool nofollow = false); + TFileStat(const char* fileName, bool nofollow = false); + + friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept; + friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept; + +private: + void MakeFromFileName(const char* fileName, bool nofollow); +}; + +i64 GetFileLength(FHANDLE fd); +i64 GetFileLength(const char* name); +i64 GetFileLength(const TString& name); |