30 explicit File(
const std::filesystem::path& path,
int flags = O_CREAT | O_RDWR | O_APPEND, mode_t mode = S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP);
41 void initialize(
const std::filesystem::path& path,
int flags = O_CREAT | O_RDWR | O_APPEND, mode_t mode = S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP);
47 void open(
const std::string& path,
int flags = O_CREAT | O_RDWR | O_APPEND, mode_t mode = S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP);
66 void open(
bool reopen =
false);
72 [[nodiscard]]
bool isOpen()
const;
91 void write(
const File& f,
size_t pos,
size_t sz,
size_t buf_sz = 0);
97 void write(
const void* buf,
size_t sz,
size_t* written =
nullptr);
99 void write(
const std::string& s);
101 void write(
const char* s);
109 void write(
const T& t);
115 ssize_t
read(
void* buf,
size_t pos,
size_t sz)
const;
132 void read(T& t,
size_t pos)
const;
143 [[nodiscard]]
const stat_type& getStatus()
const;
161 void rename(
const std::string& path,
bool assign =
false);
183 [[nodiscard]] std::string getPath()
const;
188 [[nodiscard]] mode_t getMode()
const;
193 [[nodiscard]]
int getFlags()
const;
198 [[nodiscard]]
int getDescriptor()
const;
215 int setErrorNo(
int error_no);
219 std::filesystem::path _path;
283 write(s.c_str(), s.length());
294 write(&t,
sizeof(T));
300 read(&t, pos,
sizeof(T));
305 return _descriptor != -1;
mode_t getMode() const
Definition File.h:252
bool isOpen() const
Definition File.h:303
struct stat stat_type
Definition File.h:20
void write(const void *buf, size_t sz, size_t *written=nullptr)
bool close(bool exceptions)
void getStat(stat_type &s) const
void truncate(size_t length)
void rename(const std::string &path, bool assign=false)
File(const std::filesystem::path &path, int flags=O_CREAT|O_RDWR|O_APPEND, mode_t mode=S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP)
const stat_type & getStatus() const
Definition File.h:267
std::string getPath() const
Definition File.h:247
void open(const std::string &path, int flags=O_CREAT|O_RDWR|O_APPEND, mode_t mode=S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP)
std::string getStatText() const
void open(bool reopen=false)
void createTemporary(const std::string &name_tpl, int flags=O_CREAT|O_RDWR)
int getFlags() const
Definition File.h:257
void initialize(const std::filesystem::path &path, int flags=O_CREAT|O_RDWR|O_APPEND, mode_t mode=S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP)
void read(DynamicBuffer buf, size_t pos, size_t sz) const
void close()
Definition File.h:262
int getDescriptor() const
Definition File.h:242
void write(const File &f, size_t pos, size_t sz, size_t buf_sz=0)
ssize_t read(void *buf, size_t pos, size_t sz) const
#define _MISC_FUNC
Definition misc/global.h:39
#define _MISC_CLASS
Definition misc/global.h:40
_MISC_FUNC std::ostream & operator<<(std::ostream &stream, const File &file)
File class out stream operator.