SPH
Classes | Namespaces | Enumerations | Functions
FileSystem.h File Reference
#include "io/Path.h"
#include "objects/containers/Array.h"
#include "objects/wrappers/Expected.h"
#include "objects/wrappers/Flags.h"
#include "objects/wrappers/Outcome.h"
#include <dirent.h>

Go to the source code of this file.

Classes

class  FileSystem::ScopedWorkingDirectory
 
class  FileSystem::DirectoryIterator
 Iterator allowing to enumerate files and subdirectories in given directory. More...
 
class  FileSystem::DirectoryAdapter
 Object providing begin and end directory iterator for given directory path. More...
 
class  FileSystem::FileLock
 Locks a file. More...
 

Namespaces

 FileSystem
 

Enumerations

enum class  FileSystem::PathType { FileSystem::FILE , FileSystem::DIRECTORY , FileSystem::SYMLINK , FileSystem::OTHER }
 
enum class  FileSystem::CreateDirectoryFlag { FileSystem::ALLOW_EXISTING = 1 << 0 }
 
enum class  FileSystem::RemovePathFlag { FileSystem::RECURSIVE = 1 << 1 }
 

Functions

std::string FileSystem::readFile (const Path &path)
 Reads the whole file into the string. More...
 
bool FileSystem::pathExists (const Path &path)
 Checks if a file or directory exists (or more precisely, if a file or directory is accessible). More...
 
Size FileSystem::fileSize (const Path &path)
 Returns the size of a file. More...
 
bool FileSystem::isPathWritable (const Path &path)
 Checks whether the given file is writable. More...
 
Expected< PathFileSystem::getHomeDirectory ()
 Returns the home directory of the current user. More...
 
Path FileSystem::getAbsolutePath (const Path &relativePath)
 Returns the absolute path to the file. More...
 
Expected< PathType > FileSystem::pathType (const Path &path)
 Returns the type of the given path, or error message if the function fails. More...
 
Outcome FileSystem::createDirectory (const Path &path, const Flags< CreateDirectoryFlag > flags=CreateDirectoryFlag::ALLOW_EXISTING)
 Creates a directory with given path. Creates all parent directories as well. More...
 
Outcome FileSystem::removePath (const Path &path, const Flags< RemovePathFlag > flags=EMPTY_FLAGS)
 
Outcome FileSystem::copyFile (const Path &from, const Path &to)
 Copies a file on given path to a different path. More...
 
Outcome FileSystem::copyDirectory (const Path &from, const Path &to)
 Copies a directory (and all files and subdirectories it contains) to a different path. More...
 
void FileSystem::setWorkingDirectory (const Path &path)
 Changes the current working directory. More...
 
DirectoryAdapter FileSystem::iterateDirectory (const Path &directory)
 
Array< PathFileSystem::getFilesInDirectory (const Path &directory)
 Alternatitve to iterateDirectory, returning all files in directory in an array. More...
 
bool FileSystem::isFileLocked (const Path &path)