winss
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
winss::FilesystemInterface Class Reference

An interface for interacting with the file system. More...

#include <filesystem_interface.hpp>

Public Member Functions

 FilesystemInterface ()
 Creates the file system interface. More...
 
 FilesystemInterface (const FilesystemInterface &)=delete
 No copy. More...
 
 FilesystemInterface (FilesystemInterface &&)=delete
 No move. More...
 
virtual std::string Read (const fs::path &path) const
 Reads the contents of the file at the given path. More...
 
virtual bool Write (const fs::path &path, const std::string &content) const
 Writes the given content to a file. More...
 
virtual bool ChangeDirectory (const fs::path &dir) const
 Change the current directory to the one given. More...
 
virtual bool DirectoryExists (const fs::path &dir) const
 Checks if the directory exists. More...
 
virtual bool CreateDirectory (const fs::path &dir) const
 Creates a directory. More...
 
virtual bool Rename (const fs::path &from, const fs::path &to) const
 Renames a file/directory. More...
 
virtual bool Remove (const fs::path &path) const
 Remove a file or empty directory. More...
 
virtual bool FileExists (const fs::path &path) const
 Checks if a file exists. More...
 
virtual fs::path Absolute (const fs::path &path) const
 Gets the absolute path. More...
 
virtual fs::path CanonicalUncPath (const fs::path &path) const
 Gets the canonical UNC path. More...
 
virtual std::vector< fs::path > GetDirectories (const fs::path &path) const
 Gets a list of directories at the given path. More...
 
virtual std::vector< fs::path > GetFiles (const fs::path &path) const
 Gets a list of files at the given path. More...
 
FilesystemInterfaceoperator= (const FilesystemInterface &)=delete
 No copy. More...
 
FilesystemInterfaceoperator= (FilesystemInterface &&)=delete
 No move. More...
 

Static Public Member Functions

static const FilesystemInterfaceGetInstance ()
 Gets the singleton instance. More...
 

Static Protected Attributes

static std::shared_ptr< FilesystemInterfaceinstance
 A singleton instance. More...
 

Detailed Description

An interface for interacting with the file system.

Constructor & Destructor Documentation

winss::FilesystemInterface::FilesystemInterface ( )
inline
winss::FilesystemInterface::FilesystemInterface ( const FilesystemInterface )
delete

No copy.

winss::FilesystemInterface::FilesystemInterface ( FilesystemInterface &&  )
delete

No move.

Member Function Documentation

fs::path winss::FilesystemInterface::Absolute ( const fs::path &  path) const
virtual

Gets the absolute path.

Parameters
[in]pathThe path to convert.
Returns
The absolute path.

Referenced by CanonicalUncPath(), and FilesystemInterface().

fs::path winss::FilesystemInterface::CanonicalUncPath ( const fs::path &  path) const
virtual

Gets the canonical UNC path.

Parameters
[in]pathThe path to convert.
Returns
The canonical UNC path.

References Absolute().

Referenced by FilesystemInterface().

bool winss::FilesystemInterface::ChangeDirectory ( const fs::path &  dir) const
virtual

Change the current directory to the one given.

Parameters
[in]dirThe directory.
Returns
True if the change directory was successful otherwise false.

Referenced by FilesystemInterface().

bool winss::FilesystemInterface::CreateDirectory ( const fs::path &  dir) const
virtual

Creates a directory.

Parameters
[in]dirThe directory.
Returns
True if the directory now exists otherwise false.

References DirectoryExists().

Referenced by FilesystemInterface().

bool winss::FilesystemInterface::DirectoryExists ( const fs::path &  dir) const
virtual

Checks if the directory exists.

Parameters
[in]dirThe directory.
Returns
True if the directory exists otherwise false.

Referenced by CreateDirectory(), and FilesystemInterface().

bool winss::FilesystemInterface::FileExists ( const fs::path &  path) const
virtual

Checks if a file exists.

Parameters
[in]pathThe file to check.
Returns
True if the file exists otherwise false.

Referenced by FilesystemInterface().

std::vector< fs::path > winss::FilesystemInterface::GetDirectories ( const fs::path &  path) const
virtual

Gets a list of directories at the given path.

Parameters
[in]pathThe path to list directories.
Returns
A list of directories.

Referenced by FilesystemInterface().

std::vector< fs::path > winss::FilesystemInterface::GetFiles ( const fs::path &  path) const
virtual

Gets a list of files at the given path.

Parameters
[in]pathThe path to list files.
Returns
A list of files.

Referenced by FilesystemInterface().

const winss::FilesystemInterface & winss::FilesystemInterface::GetInstance ( )
static

Gets the singleton instance.

Returns
The singleton instance.

References instance.

Referenced by FilesystemInterface().

FilesystemInterface& winss::FilesystemInterface::operator= ( const FilesystemInterface )
delete

No copy.

Referenced by FilesystemInterface().

FilesystemInterface& winss::FilesystemInterface::operator= ( FilesystemInterface &&  )
delete

No move.

std::string winss::FilesystemInterface::Read ( const fs::path &  path) const
virtual

Reads the contents of the file at the given path.

Parameters
[in]pathThe file path.
Returns
The contents of the file as a string. The string will be empty if the file does not exist.

Referenced by FilesystemInterface().

bool winss::FilesystemInterface::Remove ( const fs::path &  path) const
virtual

Remove a file or empty directory.

Parameters
[in]pathThe file/directory to remove.
Returns
True if the path was removed otherwise false.

Referenced by FilesystemInterface().

bool winss::FilesystemInterface::Rename ( const fs::path &  from,
const fs::path &  to 
) const
virtual

Renames a file/directory.

Parameters
[in]fromExisting file/directory.
[in]toNew file/directory.
Returns
True if the path rename was successful otherwise false.

Referenced by FilesystemInterface(), and Write().

bool winss::FilesystemInterface::Write ( const fs::path &  path,
const std::string &  content 
) const
virtual

Writes the given content to a file.

Parameters
[in]pathThe file path.
[in]contentThe content of the file.
Returns
True if the write was successful otherwise false.

References Rename().

Referenced by FilesystemInterface().

Member Data Documentation

std::shared_ptr< winss::FilesystemInterface > winss::FilesystemInterface::instance
staticprotected
Initial value:
=
std::make_shared<winss::FilesystemInterface>()

A singleton instance.

Referenced by GetInstance().


The documentation for this class was generated from the following files: