| 154 | }; |
| 155 | |
| 156 | class TFile { |
| 157 | public: |
| 158 | TFile(); |
| 159 | /// Takes ownership of handle, so closes it when the last holder of descriptor dies. |
| 160 | explicit TFile(FHANDLE fd); |
| 161 | TFile(FHANDLE fd, const TString& fname); |
| 162 | TFile(const char* fName, EOpenMode oMode); |
| 163 | TFile(const TString& fName, EOpenMode oMode); |
| 164 | TFile(const std::filesystem::path& path, EOpenMode oMode); |
| 165 | ~TFile(); |
| 166 | |
| 167 | void Close(); |
| 168 | |
| 169 | const TString& GetName() const noexcept; |
| 170 | i64 GetPosition() const noexcept; |
| 171 | i64 GetLength() const noexcept; |
| 172 | bool IsOpen() const noexcept; |
| 173 | FHANDLE GetHandle() const noexcept; |
| 174 | |
| 175 | i64 Seek(i64 offset, SeekDir origin); |
| 176 | void Resize(i64 length); |
| 177 | void Reserve(i64 length); |
| 178 | void FallocateNoResize(i64 length); |
| 179 | void ShrinkToFit(); |
| 180 | void Flush(); |
| 181 | void FlushData(); |
| 182 | |
| 183 | void LinkTo(const TFile& f) const; |
| 184 | TFile Duplicate() const; |
| 185 | |
| 186 | // Reads up to 1 GB without retrying, returns -1 on error |
| 187 | i32 RawRead(void* buf, size_t len); |
| 188 | // Reads up to 1 GB without retrying, throws on error |
| 189 | size_t ReadOrFail(void* buf, size_t len); |
| 190 | // Retries incomplete reads until EOF, throws on error |
| 191 | size_t Read(void* buf, size_t len); |
| 192 | // Reads exactly len bytes, throws on premature EOF or error |
| 193 | void Load(void* buf, size_t len); |
| 194 | |
| 195 | // Retries incomplete writes, will either write len bytes or throw |
| 196 | void Write(const void* buf, size_t len); |
| 197 | |
| 198 | // Retries incomplete reads until EOF, throws on error |
| 199 | size_t Pread(void* buf, size_t len, i64 offset) const; |
| 200 | // Single pread call |
| 201 | i32 RawPread(void* buf, ui32 len, i64 offset) const; |
| 202 | // Reads exactly len bytes, throws on premature EOF or error |
| 203 | void Pload(void* buf, size_t len, i64 offset) const; |
| 204 | |
| 205 | // Retries incomplete writes, will either write len bytes or throw |
| 206 | void Pwrite(const void* buf, size_t len, i64 offset) const; |
| 207 | |
| 208 | void Flock(int op); |
| 209 | |
| 210 | // do not use, their meaning very platform-dependant |
| 211 | void SetDirect(); |
| 212 | void ResetDirect(); |
| 213 |
no outgoing calls
no test coverage detected