40 #ifndef GEOGRAM_BASIC_FILE_SYSTEM
41 #define GEOGRAM_BASIC_FILE_SYSTEM
62 namespace FileSystem {
89 virtual bool is_file(
const std::string& path);
139 const std::string& path, std::vector<std::string>& result
156 const std::string& path
172 const std::string& old_name,
const std::string& new_name
198 virtual bool touch(
const std::string& filename);
278 const std::string& path,
bool remove_extension =
true
296 virtual std::string
dir_name(
const std::string& path);
311 const std::string& path,
312 std::vector<std::string>& result,
bool recursive
329 const std::string& path,
330 std::vector<std::string>& result,
bool recursive =
false
347 const std::string& path,
348 std::vector<std::string>& result,
bool recursive =
false
367 const std::string& from,
const std::string& to
386 const std::string& from,
const std::string& to
393 virtual bool is_file(
const std::string& path)
override;
409 const std::string& path, std::vector<std::string>& result
415 const std::string& old_name,
const std::string& new_name
441 const std::string& path, std::string& leadingsubdir,
447 std::map<std::string, SmartPointer<MemoryNode> > subnodes_;
448 std::map<std::string, const char*> files_;
472 bool GEOGRAM_API
is_file(
const std::string& path);
495 const std::string& path,
bool create_missing_directories =
false
509 const std::string& path, std::vector<std::string>& result
514 bool GEOGRAM_API set_current_working_directory(
515 const std::string& path
520 const std::string& old_name,
const std::string& new_name
525 const std::string& path
529 std::string GEOGRAM_API
extension(
const std::string& path);
533 const std::string& path,
bool remove_extension =
true
537 std::string GEOGRAM_API
dir_name(
const std::string& path);
541 const std::string& path,
542 std::vector<std::string>& result,
bool recursive
547 const std::string& path,
548 std::vector<std::string>& result,
bool recursive =
false
553 const std::string& path,
554 std::vector<std::string>& result,
bool recursive =
false
562 const std::string& from,
const std::string& to
569 bool GEOGRAM_API
touch(
const std::string& filename);
590 #ifdef GEO_OS_EMSCRIPTEN
598 void set_file_system_changed_callback(
void(*callback)());
Base class for reference-counted objects.
Implementation of a file system stored in memory.
bool create_file(const std::string &path, const char *content)
Creates a file.
static void split_path(const std::string &path, std::string &leadingsubdir, std::string &rest)
Splits a path.
const char * get_file_contents(const std::string &path)
Gets the contents of a file.
virtual bool delete_file(const std::string &path) override
Deletes a file.
virtual bool is_directory(const std::string &path) override
Checks if a path is a directory.
virtual bool delete_directory(const std::string &path) override
Deletes a directory.
bool copy_file(const std::string &from, const std::string &to) override
Copies a file.
virtual bool is_file(const std::string &path) override
Checks if a path is a regular file.
MemoryNode(const std::string &path="/")
MemoryNode constructor.
virtual bool create_directory(const std::string &path) override
Creates a directory.
bool rename_file(const std::string &old_name, const std::string &new_name) override
Renames or moves a file.
bool get_directory_entries(const std::string &path, std::vector< std::string > &result) override
Lists directory contents.
std::string load_file_as_string(const std::string &path) override
Load file contents in a string.
virtual bool copy_file(const std::string &from, const std::string &to)
Copies a file.
virtual void get_subdirectories(const std::string &path, std::vector< std::string > &result, bool recursive=false)
Lists sub-directories in a directory.
virtual bool rename_file(const std::string &old_name, const std::string &new_name)
Renames or moves a file.
virtual std::string load_file_as_string(const std::string &path)
Load file contents in a string.
virtual void flip_slashes(std::string &path)
Converts a path to Unix format.
virtual std::string extension(const std::string &path)
Gets a path extension.
virtual bool delete_file(const std::string &path)
Deletes a file.
virtual bool touch(const std::string &filename)
Modifies the last modification time of a file.
virtual Numeric::uint64 get_time_stamp(const std::string &path)
Gets a file last modification time.
virtual std::string home_directory()
Gets the current user's home directory.
virtual bool set_executable_flag(const std::string &filename)
Marks a filename as executable.
virtual std::string base_name(const std::string &path, bool remove_extension=true)
Gets a path base name.
virtual void get_directory_entries(const std::string &path, std::vector< std::string > &result, bool recursive)
Lists directory contents.
virtual bool is_file(const std::string &path)
Checks if a path is a regular file.
virtual std::string dir_name(const std::string &path)
Gets a path directory.
virtual void get_files(const std::string &path, std::vector< std::string > &result, bool recursive=false)
Lists files in a directory.
virtual bool set_current_working_directory(const std::string &path)
Sets the working directory.
virtual bool delete_directory(const std::string &path)
Deletes a directory.
virtual bool is_directory(const std::string &path)
Checks if a path is a directory.
virtual std::string documents_directory()
Gets the current user's home directory.
virtual bool create_directory(const std::string &path)
Creates a directory.
virtual bool get_directory_entries(const std::string &path, std::vector< std::string > &result)
Lists directory contents.
virtual std::string normalized_path(const std::string &path)
Normalizes a path.
~Node() override
Node destructor.
virtual std::string get_current_working_directory()
Gets the current working directory.
A smart pointer with reference-counted copy semantics.
Base class of reference-counted objects, to be used with smart pointers.
Common include file, providing basic definitions. Should be included before anything else by all head...
bool copy_file(const std::string &from, const std::string &to)
Copies a file.
std::string absolute_path(const std::string &path)
void get_files(const std::string &path, std::vector< std::string > &result, bool recursive=false)
Lists files in a directory.
bool delete_file(const std::string &path)
Deletes a file.
std::string home_directory()
Gets the current user's home directory.
void terminate()
Terminates the FileSystem library.
bool can_read_directory(const std::string &path)
Tests whether one can read files from a directory.
std::string dir_name(const std::string &path)
Gets a path directory.
std::string get_current_working_directory()
Gets the current working directory.
void get_root(Node *&root)
Gets the root of the file system.
bool rename_file(const std::string &old_name, const std::string &new_name)
Renames or moves a file.
void get_subdirectories(const std::string &path, std::vector< std::string > &result, bool recursive=false)
Lists sub-directories in a directory.
std::string normalized_path(const std::string &path)
Normalizes a path.
bool set_executable_flag(const std::string &filename)
Marks a filename as executable.
bool is_file(const std::string &path)
Checks if a path is a regular file.
bool touch(const std::string &filename)
Modifies the last modification time of a file.
std::string base_name(const std::string &path, bool remove_extension=true)
Gets a path base name.
bool create_directory(const std::string &path)
Creates a directory.
void flip_slashes(std::string &path)
Converts a path to Unix format.
std::string documents_directory()
Gets the current user's home directory.
bool get_directory_entries(const std::string &path, std::vector< std::string > &result)
Lists directory contents.
bool is_directory(const std::string &path)
Checks if a path is a directory.
std::string extension(const std::string &path)
Gets a path extension.
bool can_write_directory(const std::string &path, bool create_missing_directories=false)
Tests whether a directory can be written to.
bool delete_directory(const std::string &path)
Deletes a directory.
void initialize()
Initializes the FileSystem library.
Numeric::uint64 get_time_stamp(const std::string &path)
Gets a file last modification time.
Global Vorpaline namespace.
Types and functions for numbers manipulation.
Pointers with automatic reference counting.