|
Geogram Version 1.9.7
A programming library of geometric algorithms
|
Implementation of a file system stored in memory. More...
#include <geogram/basic/file_system.h>
Public Member Functions | |
| MemoryNode (const std::string &path="/") | |
| MemoryNode constructor. | |
| bool | copy_file (const std::string &from, const std::string &to) override |
| Copies a file. | |
| std::string | load_file_as_string (const std::string &path) override |
| Load file contents in a string. | |
| virtual bool | is_file (const std::string &path) override |
| Checks if a path is a regular file. | |
| virtual bool | is_directory (const std::string &path) override |
| Checks if a path is a directory. | |
| virtual bool | create_directory (const std::string &path) override |
| Creates a directory. | |
| virtual bool | delete_directory (const std::string &path) override |
| Deletes a directory. | |
| virtual bool | delete_file (const std::string &path) override |
| Deletes a file. | |
| bool | get_directory_entries (const std::string &path, std::vector< std::string > &result) override |
| Lists directory contents. | |
| bool | rename_file (const std::string &old_name, const std::string &new_name) override |
| Renames or moves a file. | |
| const char * | get_file_contents (const std::string &path) |
| Gets the contents of a file. | |
| bool | create_file (const std::string &path, const char *content) |
| Creates a file. | |
Public Member Functions inherited from GEO::FileSystem::Node | |
| Node () | |
| Node constructor. | |
| ~Node () override | |
| Node destructor. | |
| virtual std::string | get_current_working_directory () |
| Gets the current working directory. | |
| virtual bool | set_current_working_directory (const std::string &path) |
| Sets the working directory. | |
| virtual Numeric::uint64 | get_time_stamp (const std::string &path) |
| Gets a file last modification time. | |
| virtual bool | set_executable_flag (const std::string &filename) |
| Marks a filename as executable. | |
| virtual bool | touch (const std::string &filename) |
| Modifies the last modification time of a file. | |
| virtual std::string | normalized_path (const std::string &path) |
| Normalizes a path. | |
| virtual std::string | home_directory () |
| Gets the current user's home directory. | |
| virtual std::string | documents_directory () |
| Gets the current user's home directory. | |
| virtual std::string | extension (const std::string &path) |
| Gets a path extension. | |
| virtual std::string | base_name (const std::string &path, bool remove_extension=true) |
| Gets a path base name. | |
| virtual std::string | dir_name (const std::string &path) |
| Gets a path directory. | |
| virtual void | get_directory_entries (const std::string &path, std::vector< std::string > &result, bool recursive) |
| Lists directory contents. | |
| virtual void | get_files (const std::string &path, std::vector< std::string > &result, bool recursive=false) |
| Lists files in a directory. | |
| virtual void | get_subdirectories (const std::string &path, std::vector< std::string > &result, bool recursive=false) |
| Lists sub-directories in a directory. | |
| virtual void | flip_slashes (std::string &path) |
| Converts a path to Unix format. | |
Public Member Functions inherited from GEO::Counted | |
| void | ref () const |
| Increments the reference count. | |
| void | unref () const |
| Decrements the reference count. | |
| bool | is_shared () const |
| Check if the object is shared. | |
| int | nb_refs () const |
| Gets the number of references that point to this object. | |
Static Protected Member Functions | |
| static void | split_path (const std::string &path, std::string &leadingsubdir, std::string &rest) |
| Splits a path. | |
Additional Inherited Members | |
Static Public Member Functions inherited from GEO::Counted | |
| static void | ref (const Counted *counted) |
| Increments the reference count. | |
| static void | unref (const Counted *counted) |
| Decrements the reference count. | |
Protected Member Functions inherited from GEO::Counted | |
| Counted () | |
| Creates a reference counted object. | |
| virtual | ~Counted () |
| Destroys a reference counted object. | |
Implementation of a file system stored in memory.
Definition at line 374 of file file_system.h.
|
inline |
MemoryNode constructor.
| [in] | path | full path to this node. |
Definition at line 381 of file file_system.h.
|
overridevirtual |
Copies a file.
| [in] | from | name of the file to be copied |
| [out] | to | name of the copy |
| true | if the copy was successful |
| false | otherwise |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Creates a directory.
This recursively creates a new directory given by its absolute path path, creating any missing intermediate directories on the fly.
| [in] | path | absolute path to the directory to be created. |
| true | if the directory was successfully created. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
| bool GEO::FileSystem::MemoryNode::create_file | ( | const std::string & | path, |
| const char * | content | ||
| ) |
Creates a file.
| [in] | path | the path to the file |
| [in] | content | a const pointer to the contents of the file |
|
overridevirtual |
Deletes a directory.
This deletes the directory specified by path path. The path must specify an empty directory.
| [in] | path | the path of the directory to be removed. |
| true | if the directory was successfully deleted. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Deletes a file.
| [in] | path | the path of the file to be deleted. |
| true | if the file path was successfully deleted |
| false | otherwise |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Lists directory contents.
Lists all the files and sub-directories in the directory specified by path, and stores the list in result. Special entries "." and ".." are not stored in result.
| [in] | path | the path to the directory to list. |
| [in] | result | output vector of files and sub-directories. |
| true | if path specifies a readable directory. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
| const char * GEO::FileSystem::MemoryNode::get_file_contents | ( | const std::string & | path | ) |
Gets the contents of a file.
| [in] | path | the path to the file. |
|
overridevirtual |
Checks if a path is a directory.
| [in] | path | system path to verify. |
| true | if path is a directory. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Checks if a path is a regular file.
| [in] | path | system path to verify. |
| true | if path is a regular file. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Load file contents in a string.
| [in] | path | the path to the file |
Reimplemented from GEO::FileSystem::Node.
|
overridevirtual |
Renames or moves a file.
This renames the existing file or directory specified by path old_name to the new path new_name. The new name must not be the name of an existing file or directory. If old_name and new_name are not in the same directory, old_name is moved to the new_name.
| [in] | old_name | path of the file or directory to be renamed. |
| [in] | new_name | new path of the file or directory. |
| true | if the file was renamed successfully. |
| false | otherwise. |
Reimplemented from GEO::FileSystem::Node.
|
staticprotected |
Splits a path.
| [in] | path | the path |
| [out] | leadingsubdir | the leading subdirectory or the empty string |
| [out] | rest | the rest of the path |