4#include "../Foundation/Buffer.h"
5#include "../Strings/String.h"
6#include "FileSystemOperations.h"
27 bool preciseErrorMessages =
false;
68 return copyFiles(
CopyOperation{source, destination, copyFlags});
87 return copyDirectories(
CopyOperation{source, destination, copyFlags});
135 return removeDirectoriesRecursive({directory});
162 return removeEmptyDirectoriesRecursive({directory});
187 return makeDirectoriesIfNotExists({directory});
298 Result formatError(
int errorNumber,
StringView item,
bool isWindowsNativeError);
302 [[nodiscard]]
static Result fallbackCopyDirectory(
String& sourceDirectory,
String& destinationDirectory,
304 [[nodiscard]]
static Result fallbackRemoveDirectoryRecursive(
String& sourceDirectory);
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition Compiler.h:78
An heap allocated byte buffer that can optionally use an inline buffer.
Definition Buffer.h:28
A structure to describe copy flags.
Definition FileSystemOperations.h:19
A structure to describe file stats.
Definition FileSystemOperations.h:12
Specify source, destination and flags for a copy operation.
Definition FileSystem.h:44
StringView destination
Copy operation sink (can be a {relative | absolute} {file | directory} path)
Definition FileSystem.h:46
CopyFlags copyFlags
Copy operation flags (overwrite, use clone api etc.)
Definition FileSystem.h:47
StringView source
Copy operation source (can be a {relative | absolute} {file | directory} path)
Definition FileSystem.h:45
Execute fs operations { exists, copy, delete } for { files and directories }.
Definition FileSystem.h:22
Result createSymbolicLink(StringView sourceFileOrDirectory, StringView linkFile)
Creates a symbolic link at location linkFile pointing at sourceFileOrDirectory.
Result changeDirectory(StringView newDirectory)
Changes current directory.
Result removeEmptyDirectories(Span< const StringView > directories)
Removes multiple empty directories.
Result rename(StringView path, StringView newPath)
Rename a file or directory.
bool existsAndIsFile(StringView file)
Check if a file exists at given path.
Result copyDirectory(StringView source, StringView destination, CopyFlags copyFlags=CopyFlags())
Copy a single directory.
Definition FileSystem.h:85
Result writeString(StringView file, StringView text)
Replace the entire content of a file with the provided StringView.
Result removeFile(StringView source)
Remove a single file.
Definition FileSystem.h:109
Result removeEmptyDirectoryRecursive(StringView directory)
Removes an empty directory that only contains other empty directories (but no files)
Definition FileSystem.h:160
Result makeDirectoriesRecursive(Span< const StringView > directories)
Create new directories, creating also intermediate non existing directories (like posix mkdir -p)
Result init(StringView initialDirectory)
Call init function when instantiating the class to set directory for all operations using relative pa...
Result copyFiles(Span< const CopyOperation > sourceDestination)
Copies many files.
bool exists(StringView fileOrDirectory)
Check if a file or directory exists at a given path.
Result makeDirectories(Span< const StringView > directories)
Creates new directories that do not already exist.
Result write(StringView file, Span< const char > data)
Writes a block of memory to a file.
Result setLastModifiedTime(StringView file, Time::Realtime time)
Change last modified time of a given file.
Result getFileStat(StringView file, FileStat &fileStat)
Obtains stats (size, modified time) about a file.
Result removeEmptyDirectoriesRecursive(Span< const StringView > directories)
Removes multiple empty directories that only contains other empty directories (but no files)
bool existsAndIsLink(StringView file)
Check if a link exists at given path.
Result removeFileIfExists(StringView source)
Remove a single file, giving no error if it doesn't exist.
Result removeLinkIfExists(StringView source)
Remove a single link, giving no error if it doesn't exist.
Result removeDirectoryRecursive(StringView directory)
Remove single directory with its entire content (like posix rm -rf)
Definition FileSystem.h:133
Result removeEmptyDirectory(StringView directory)
Removes an empty directory.
Definition FileSystem.h:148
Result removeFiles(Span< const StringView > files)
Remove multiple files.
Result writeStringAppend(StringView file, StringView text)
Appends a StringView to a file.
bool existsAndIsDirectory(StringView directory)
Check if a directory exists at given path.
Result read(StringView file, Buffer &data)
Reads contents of a file into a SC::Buffer.
Result copyDirectories(Span< const CopyOperation > sourceDestination)
Copy many directories.
bool moveDirectory(StringView sourceDirectory, StringView destinationDirectory)
Moves a directory from source to destination.
Result copyFile(StringView source, StringView destination, CopyFlags copyFlags=CopyFlags())
Copy a single file.
Definition FileSystem.h:66
Result makeDirectoryRecursive(StringView directory)
Create a new directory, creating also intermediate non existing directories (like posix mkdir -p)
Definition FileSystem.h:200
Result makeDirectory(StringView directory)
Creates a new directory that does not already exist.
Definition FileSystem.h:175
Result removeDirectoriesRecursive(Span< const StringView > directories)
Remove multiple directories with their entire content (like posix rm -rf)
Result read(StringView file, String &data, StringEncoding encoding)
Read contents of a file into a string with given encoding.
Result makeDirectoriesIfNotExists(Span< const StringView > directories)
Creates new directories, if they don't already exist at the given path.
Result makeDirectoryIfNotExists(StringView directory)
Creates a new directory, if it doesn't already exists at the given path.
Definition FileSystem.h:185
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:12
String with compile time configurable inline storage (small string optimization)
Definition StringFormat.h:11
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:48
A non-modifiable owning string with associated encoding.
Definition String.h:29
Represents a realtime clock in milliseconds since epoch (use Realtime::now for current time)
Definition Time.h:192