4#include "../Foundation/Buffer.h"
5#include "../Foundation/Result.h"
6#include "../Strings/String.h"
7#include "../Time/Time.h"
12struct StringConverter;
49 useCloneIfSupported =
true;
66 useCloneIfSupported = value;
73 bool useCloneIfSupported;
325 Result formatError(
int errorNumber,
StringView item,
bool isWindowsNativeError);
329 [[nodiscard]]
static Result fallbackCopyDirectory(
String& sourceDirectory,
String& destinationDirectory,
331 [[nodiscard]]
static Result fallbackRemoveDirectoryRecursive(
String& sourceDirectory);
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition: Compiler.h:78
StringEncoding
String Encoding (Ascii, Utf8, Utf16)
Definition: StringIterator.h:17
@ Native
Encoding is UTF8.
An heap allocated byte buffer that can optionally use an inline buffer.
Definition: Buffer.h:25
Specify copy options like overwriting existing files.
Definition: FileSystem.h:45
CopyFlags & setUseCloneIfSupported(bool value)
If true copy will use native filesystem clone os api.
Definition: FileSystem.h:64
CopyFlags & setOverwrite(bool value)
If true copy will overwrite existing files in the destination.
Definition: FileSystem.h:55
Specify source, destination and flags for a copy operation.
Definition: FileSystem.h:78
StringView destination
Copy operation sink (can be a {relative | absolute} {file | directory} path)
Definition: FileSystem.h:80
CopyFlags copyFlags
Copy operation flags (overwrite, use clone api etc.)
Definition: FileSystem.h:81
StringView source
Copy operation source (can be a {relative | absolute} {file | directory} path)
Definition: FileSystem.h:79
A structure to describe modified time.
Definition: FileSystem.h:302
Time::Realtime modifiedTime
Time when file was last modified.
Definition: FileSystem.h:304
Execute fs operations { exists, copy, delete } for { files and directories }.
Definition: FileSystem.h:26
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.
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:119
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:133
Result removeEmptyDirectoryRecursive(StringView directory)
Removes an empty directory that only contains other empty directories (but no files)
Definition: FileSystem.h:184
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:157
Result removeEmptyDirectory(StringView directory)
Removes an empty directory.
Definition: FileSystem.h:172
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.
bool preciseErrorMessages
Formats errors in an internal buffer when returning failed Result.
Definition: FileSystem.h:31
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:100
Result makeDirectoryRecursive(StringView directory)
Create a new directory, creating also intermediate non existing directories (like posix mkdir -p)
Definition: FileSystem.h:224
Result makeDirectory(StringView directory)
Creates a new directory that does not already exist.
Definition: FileSystem.h:199
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:209
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: String.h:168
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:24
A non-modifiable owning string with associated encoding.
Definition: String.h:29
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
Represents a realtime clock in milliseconds since epoch (use Realtime::now for current time)
Definition: Time.h:192