X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fio%2Ffilesystem.hpp;fp=src%2Fio%2Ffilesystem.hpp;h=154b812fde01d7101fe0d2d851018acd8bdc9954;hb=34e833025f0616ab4b86b808d0ce1cc49cecce5d;hp=0000000000000000000000000000000000000000;hpb=698d8120797383886d1386d3a8ac4b5fc1ca7f16;p=blobs.git diff --git a/src/io/filesystem.hpp b/src/io/filesystem.hpp new file mode 100644 index 0000000..154b812 --- /dev/null +++ b/src/io/filesystem.hpp @@ -0,0 +1,49 @@ +#ifndef BLOBS_IO_FILESYSTEM_HPP_ +#define BLOBS_IO_FILESYSTEM_HPP_ + +#include +#include + + +namespace blobs { +namespace io { + +/// check if give path points to an existing directory +bool is_dir(const char *); +inline bool is_dir(const std::string &s) { + return is_dir(s.c_str()); +} +/// check if give path points to an existing file +bool is_file(const char *); +inline bool is_file(const std::string &s) { + return is_file(s.c_str()); +} +/// get timestamp of last modification +std::time_t file_mtime(const char *); +inline std::time_t file_mtime(const std::string &s) { + return file_mtime(s.c_str()); +} + +/// create given directory +/// @return true if the directory was created +/// the directory might already exist, see errno +bool make_dir(const char *); +inline bool make_dir(const std::string &s) { + return make_dir(s.c_str()); +} +/// create given directory and all parents +/// @return true if the directory was created or already exists +bool make_dirs(const std::string &); + +/// remove given file +/// @return true on success +bool remove_file(const std::string &); +/// recursively remove given directory +/// may leave the directory partially removed on failure +/// @return true if the directory was completely removed +bool remove_dir(const std::string &); + +} +} + +#endif