17 #ifndef LIB_WINSS_FILESYSTEM_INTERFACE_HPP_ 18 #define LIB_WINSS_FILESYSTEM_INTERFACE_HPP_ 26 #define FILESYSTEM winss::FilesystemInterface::GetInstance() 28 namespace fs = std::experimental::filesystem;
37 static std::shared_ptr<FilesystemInterface>
instance;
54 virtual std::string
Read(
const fs::path& path)
const;
63 virtual bool Write(
const fs::path& path,
const std::string& content)
const;
96 virtual bool Rename(
const fs::path& from,
const fs::path& to)
const;
104 virtual bool Remove(
const fs::path& path)
const;
112 virtual bool FileExists(
const fs::path& path)
const;
120 virtual fs::path
Absolute(
const fs::path& path)
const;
136 virtual std::vector<fs::path>
GetDirectories(
const fs::path& path)
const;
144 virtual std::vector<fs::path>
GetFiles(
const fs::path& path)
const;
160 #endif // LIB_WINSS_FILESYSTEM_INTERFACE_HPP_ virtual bool ChangeDirectory(const fs::path &dir) const
Change the current directory to the one given.
Definition: filesystem_interface.cpp:70
Definition: case_ignore.hpp:23
FilesystemInterface()
Creates the file system interface.
Definition: filesystem_interface.hpp:43
virtual bool DirectoryExists(const fs::path &dir) const
Checks if the directory exists.
Definition: filesystem_interface.cpp:81
An interface for interacting with the file system.
Definition: filesystem_interface.hpp:34
FilesystemInterface & operator=(const FilesystemInterface &)=delete
No copy.
virtual bool CreateDirectory(const fs::path &dir) const
Creates a directory.
Definition: filesystem_interface.cpp:91
virtual fs::path CanonicalUncPath(const fs::path &path) const
Gets the canonical UNC path.
Definition: filesystem_interface.cpp:158
virtual fs::path Absolute(const fs::path &path) const
Gets the absolute path.
Definition: filesystem_interface.cpp:149
virtual std::vector< fs::path > GetDirectories(const fs::path &path) const
Gets a list of directories at the given path.
Definition: filesystem_interface.cpp:199
static std::shared_ptr< FilesystemInterface > instance
A singleton instance.
Definition: filesystem_interface.hpp:37
virtual std::string Read(const fs::path &path) const
Reads the contents of the file at the given path.
Definition: filesystem_interface.cpp:32
virtual std::vector< fs::path > GetFiles(const fs::path &path) const
Gets a list of files at the given path.
Definition: filesystem_interface.cpp:222
virtual bool Write(const fs::path &path, const std::string &content) const
Writes the given content to a file.
Definition: filesystem_interface.cpp:51
static const FilesystemInterface & GetInstance()
Gets the singleton instance.
Definition: filesystem_interface.cpp:245
virtual bool Remove(const fs::path &path) const
Remove a file or empty directory.
Definition: filesystem_interface.cpp:126
virtual bool FileExists(const fs::path &path) const
Checks if a file exists.
Definition: filesystem_interface.cpp:137
virtual bool Rename(const fs::path &from, const fs::path &to) const
Renames a file/directory.
Definition: filesystem_interface.cpp:107