fstat.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <util/generic/fwd.h>
  3. #include <util/system/fhandle.h>
  4. class TFile;
  5. class TFsPath;
  6. struct stat;
  7. struct TFileStat {
  8. ui32 Mode = 0; /* protection */
  9. ui32 Uid = 0; /* user ID of owner */
  10. ui32 Gid = 0; /* group ID of owner */
  11. ui64 NLinks = 0; /* number of hard links */
  12. ui64 Size = 0; /* total size, in bytes */
  13. ui64 INode = 0; /* inode number */
  14. ui64 AllocationSize = 0; /* number of bytes allocated on the disk */
  15. time_t ATime = 0; /* time of last access */
  16. time_t MTime = 0; /* time of last modification */
  17. time_t CTime = 0; /* time of last status change */
  18. public:
  19. TFileStat();
  20. bool IsNull() const noexcept;
  21. bool IsFile() const noexcept;
  22. bool IsDir() const noexcept;
  23. bool IsSymlink() const noexcept;
  24. explicit TFileStat(const struct stat& fs);
  25. explicit TFileStat(const TFile& f);
  26. explicit TFileStat(FHANDLE f);
  27. TFileStat(const TFsPath& fileName, bool nofollow = false);
  28. TFileStat(const TString& fileName, bool nofollow = false);
  29. TFileStat(const char* fileName, bool nofollow = false);
  30. friend bool operator==(const TFileStat& l, const TFileStat& r) noexcept;
  31. friend bool operator!=(const TFileStat& l, const TFileStat& r) noexcept;
  32. private:
  33. void MakeFromFileName(const char* fileName, bool nofollow);
  34. };
  35. i64 GetFileLength(FHANDLE fd);
  36. i64 GetFileLength(const char* name);
  37. i64 GetFileLength(const TString& name);