fstat.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. long ATimeNSec = 0; /* nsec of last access */
  17. time_t MTime = 0; /* time of last modification */
  18. long MTimeNSec = 0; /* nsec of last modification */
  19. time_t CTime = 0; /* time of last status change */
  20. long CTimeNSec = 0; /* nsec of last status change */
  21. TFileStat();
  22. bool IsNull() const noexcept;
  23. bool IsFile() const noexcept;
  24. bool IsDir() const noexcept;
  25. bool IsSymlink() const noexcept;
  26. #if defined(_unix_)
  27. explicit TFileStat(const struct stat& fs);
  28. #endif
  29. explicit TFileStat(const TFile& f);
  30. explicit TFileStat(FHANDLE f);
  31. TFileStat(const TFsPath& fileName, bool nofollow = false);
  32. TFileStat(const TString& fileName, bool nofollow = false);
  33. TFileStat(const char* fileName, bool nofollow = false);
  34. bool operator==(const TFileStat& other) const noexcept;
  35. private:
  36. void MakeFromFileName(const char* fileName, bool nofollow);
  37. };
  38. i64 GetFileLength(FHANDLE fd);
  39. i64 GetFileLength(const char* name);
  40. i64 GetFileLength(const TString& name);