diff options
author | Alexander Fokin <[email protected]> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:38 +0300 |
commit | bf9e69a933f89af083d895185f01ed65e4d90766 (patch) | |
tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/system/fstat.cpp | |
parent | 863a59a65247c24db7cb06789bc5cf79d04da32f (diff) |
Restoring authorship annotation for Alexander Fokin <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'util/system/fstat.cpp')
-rw-r--r-- | util/system/fstat.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/util/system/fstat.cpp b/util/system/fstat.cpp index 2550d66dcdb..81e98cbc6bb 100644 --- a/util/system/fstat.cpp +++ b/util/system/fstat.cpp @@ -133,9 +133,9 @@ TFileStat::TFileStat(const char* fileName, bool nofollow) { } bool TFileStat::IsNull() const noexcept { - return *this == TFileStat(); -} - + return *this == TFileStat(); +} + bool TFileStat::IsFile() const noexcept { return S_ISREG(Mode); } @@ -157,12 +157,12 @@ bool operator==(const TFileStat& l, const TFileStat& r) noexcept { l.ATime == r.ATime && l.MTime == r.MTime && l.CTime == r.CTime; -} - +} + bool operator!=(const TFileStat& l, const TFileStat& r) noexcept { - return !(l == r); -} - + return !(l == r); +} + i64 GetFileLength(FHANDLE fd) { #if defined(_win_) LARGE_INTEGER pos; @@ -184,32 +184,32 @@ i64 GetFileLength(FHANDLE fd) { #error unsupported platform #endif } - -i64 GetFileLength(const char* name) { -#if defined(_win_) - WIN32_FIND_DATA fData; - HANDLE h = FindFirstFileA(name, &fData); - if (h == INVALID_HANDLE_VALUE) - return -1; - FindClose(h); - return (((i64)fData.nFileSizeHigh) * (i64(MAXDWORD) + 1)) + (i64)fData.nFileSizeLow; -#elif defined(_unix_) - struct stat buf; - int r = ::stat(name, &buf); + +i64 GetFileLength(const char* name) { +#if defined(_win_) + WIN32_FIND_DATA fData; + HANDLE h = FindFirstFileA(name, &fData); + if (h == INVALID_HANDLE_VALUE) + return -1; + FindClose(h); + return (((i64)fData.nFileSizeHigh) * (i64(MAXDWORD) + 1)) + (i64)fData.nFileSizeLow; +#elif defined(_unix_) + struct stat buf; + int r = ::stat(name, &buf); if (r == -1) { - return -1; + return -1; } if (!(buf.st_mode & (S_IFREG | S_IFBLK | S_IFCHR))) { // st_size only makes sense for regular files or devices errno = EINVAL; return -1; } - return (i64)buf.st_size; -#else + return (i64)buf.st_size; +#else #error unsupported platform -#endif -} - +#endif +} + i64 GetFileLength(const TString& name) { return GetFileLength(name.data()); -} +} |