26 FILEWrapper(
const std::string& path,
const char* mode);
32 bool try_open(
const std::string& path,
const char* mode);
35 bool end_of_file()
const;
37 void read_or_die(
void* dest,
size_t nbytes);
40 size_t try_read(
void* dest,
size_t nbytes);
42 void write(
const void* src,
size_t nbytes);
48 void seek(
int offset,
int origin);
67 bool file_exists(
const std::string& path);
68 size_t file_size(
const std::string& path);
69 time_t modified_time(
const std::string& path);
70 bool is_file(
const std::string& path);
71 bool is_directory(
const std::string& path);
72 std::vector<uint8_t> read_binary_file(
const std::string& path);
73 std::string read_text_file(
const std::string& path);
74 void write_binary_file(
const std::string& path,
const void* data,
size_t nbytes);
75 void write_text_file(
const std::string& path,
const char* text);
77 std::vector<std::string> files_in_directory(
const std::string& path);
79 void print_tree(
const std::string& path,
const std::string& indent =
"");
82 void walk_dir(
const std::string& path,
const std::function<
void(
const std::string&)>& visitor);
88 std::string file_ending(
const std::string& path);
91 std::string without_ending(
const std::string& path);
94 std::string strip_path(
const std::string& dir_path,
const std::string& file_path);
97 std::string file_dir(
const std::string& path);
100 std::string file_name(
const std::string& path);
103 const char* file_name(
const char* path);
bool read_line(char *dest, int nbytes)
Returns true on success.
bool try_open(const std::string &path, const char *mode)
Nice version.
Definition: file_system.hpp:18
void seek(int offset, int origin)
Origin = SEEK_SET, SEEK_CUR or SEEK_END.
Definition: file_system.hpp:20
size_t try_read(void *dest, size_t nbytes)
Returns the number of read bytes.