A file on the local file system. More...
#include <File.hpp>
Classes | |
class | FileIterator |
Non-recursive iteration over a directory's contents. More... | |
class | FileUriIterator |
Non-recursive iteration over a directory's contents (URI version). More... | |
class | RecursiveFileIterator |
Recursive iteration into a directory structure. More... | |
class | RecursiveFileUriIterator |
Recursive iteration into a directory structure (URI version). More... | |
Public Member Functions | |
File ()=default | |
Create an empty file URI. More... | |
File (boost::filesystem::directory_entry entry_) | |
Create a file from the supplied directory entry. More... | |
File (const boost::filesystem::path &entry_) | |
Create a file from the supplied Boost path. More... | |
File (const std::string &path) | |
Create a file path with the supplied path string. More... | |
File (const char *path) | |
Create a file path with the supplied path string. More... | |
File (std::string_view path) | |
Create a file path with the supplied path string. More... | |
File (const std::string &path, const std::string &name) | |
Create a file path with the supplied path string and filename string. More... | |
File (const File &path, const std::string &name) | |
Create a file path with the supplied path and filename. More... | |
File (File &&file) noexcept | |
Move an existing file URI into a new File URI. More... | |
File (const File &file) | |
Copy an existing file URI into a new File URI. More... | |
std::unique_ptr< Uri > | append (const std::string &pathComponent) const override |
Appends the path component to the supplied URI, returning a new URI. More... | |
std::unique_ptr< ByteReadResource > | byteReadResource () const override |
Get a byte read resource for the URI. More... | |
std::unique_ptr< ByteWriteResource > | byteWriteResource () override |
Get a byte write resource for the URI. More... | |
bool | canReadFrom () const override |
Can data be read from the URI via a read resource. More... | |
bool | canWriteTo () const override |
Can data be written to the URI via a write resource. More... | |
std::unique_ptr< Uri > | clone () const override |
Clone the concrete Uri. More... | |
bool | createDirectories () const |
Create all intermediate directories and the final directory. More... | |
void | dispatch (UriDispatcher &dispatcher) const override |
Visitor pattern dispatching. More... | |
bool | exists () const |
Returns true if an item exits in the file system for the file URI. More... | |
virtual FileIterator | fileIterator () const |
Get a non-recursive file iterator for this file (directory). More... | |
FileByteReadResource | getByteReadResource () const |
Get a file byte read resource for this file URI. More... | |
FileByteWriteResource | getByteWriteResource () const |
Get a file byte write resource for this file URI. More... | |
File | getChildEntry (std::string child) const |
boost::filesystem::directory_entry | getEntry () const |
Get the underlying directory entry for this file URI. More... | |
std::chrono::system_clock::time_point | getModifiedTimestamp () const |
Get the modified time of the file. More... | |
File | getParentDirectory () const |
Get the parent directory of the file URI. More... | |
File | getSubDirectory (std::string subDirectory) const |
Create a new file representing the specified sub-directory of the file URI. More... | |
FileUtf32To8WriteResource | getUtf32To8WriteResource () const |
Get a file UTF-8 to UTF-32 write resource for this file URI. More... | |
FileUtf8To32ReadResource | getUtf8To32ReadResource () const |
Get a file UTF-8 to UTF-32 read resource for this file URI. More... | |
size_t | hashcode () const noexcept override |
Get the URI's hash code. More... | |
bool | isIterable () const override |
Does the URI have a non-recursive iterator (examples: file and zip archive URIs). More... | |
bool | isRecursivelyIterable () const override |
Does the URI have a recursive iterator (examples: file and zip archive URIs). More... | |
bool | isRegularDirectory () const override |
Returns true if the file URI points to a directory. More... | |
bool | isRegularFile () const override |
Returns true if the file URI points to a regular file. More... | |
std::unique_ptr< UriIterator > | iterator () const override |
Get a (non-recursive) iterator. More... | |
File | operator+ (const std::string &fragment) const |
Concatenate the supplied path fragment to the end of the path represented by the file. More... | |
File | operator/ (const char *component) const |
Append a path component to the path represented by the file. More... | |
File | operator/ (const std::string &component) const |
Append a path component to the path represented by the file. More... | |
File | operator/ (const std::string_view &component) const |
Append a path component to the path represented by the file. More... | |
template<typename ... T, template< typename ... > class Container> | |
File | operator/ (const Container< T ... > &container) const |
Append a sequence of path components to the path represented by the file. More... | |
File & | operator/= (const char *component) |
Append a path component to the path represented by the file in place. More... | |
File & | operator/= (const std::string &component) |
Append a path component to the path represented by the file in place. More... | |
File & | operator/= (const std::string_view &component) |
Append a path component to the path represented by the file in place. More... | |
bool | operator< (const File &rhs) const |
Return true if the current object is less than the supplied instance. More... | |
File & | operator= (const File &file) |
Copy assign the supplied file to this file. More... | |
File & | operator= (File &&file) noexcept |
Move assign the supplied file to this file. More... | |
File & | operator= (const boost::filesystem::directory_entry &entry_) |
Copy the supplied directory entry to this file. More... | |
File & | operator= (const boost::filesystem::path &path) |
Copy the supplied file system path to this file. More... | |
bool | operator== (const File &rhs) const |
Compare the supplied file to the current file. More... | |
bool | operator== (const Uri &rhs) const override |
Compare the supplied URI to the current URI. More... | |
virtual RecursiveFileIterator | recursiveFileIterator () const |
Get a recursive file iterator for this file (directory). More... | |
std::unique_ptr< RecursiveUriIterator > | recursiveIterator () const override |
Get a recursive iterator. More... | |
File | relative (const File &base) const |
Get the relative path of the current object, compared to the supplied file. More... | |
bool | removeFile () const |
Remove the file if it exists. More... | |
std::unique_ptr< Uri > | resolve (std::string_view path) const override |
Resolve the relative or absolute path, in reference to the current URI. More... | |
size_t | size () const |
Get the size of the file if it exists or -1 if the file does not exist. More... | |
File | toAbsolutePath () const |
Convert the file to an absolute path if it is relative, using the current working directory. More... | |
std::string | toRawString () const override |
Get a string representing the raw URI. More... | |
template<typename AllocatorT > | |
Balau::U8String< AllocatorT > | toRawString () const |
Get a string representing the raw URI. More... | |
std::string | toUriString () const override |
Get a string representing the URI, complete with scheme. More... | |
std::unique_ptr< Utf32To8WriteResource > | utf32To8WriteResource () override |
Get a UTF-32 to UTF-8 write resource for the URI. More... | |
std::unique_ptr< Utf8To32ReadResource > | utf8To32ReadResource () const override |
Get a UTF-8 to UTF-32 read resource for the URI. More... | |
Public Member Functions inherited from Uri | |
virtual | ~Uri ()=default |
Destroy the URI instance. More... | |
std::shared_ptr< Uri > | cloneToShared () const |
Clone the concrete Uri to a shared pointer. More... | |
Static Public Attributes | |
static const boost::filesystem::path::value_type | separator = boost::filesystem::path::preferred_separator |
The path separator character for the platform. More... | |
A file on the local file system.
|
default |
Create an empty file URI.
|
inlineexplicit |
Create a file from the supplied directory entry.
|
inlineexplicit |
Create a file from the supplied Boost path.
|
inlineexplicit |
Create a file path with the supplied path string.
The path must be formatted correctly for the platform.
|
inlineexplicit |
Create a file path with the supplied path string.
The path must be formatted correctly for the platform.
|
inlineexplicit |
Create a file path with the supplied path string.
The path must be formatted correctly for the platform.
|
inline |
Create a file path with the supplied path string and filename string.
The path must be formatted correctly for the platform.
Create a file path with the supplied path and filename.
The path must be formatted correctly for the platform.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inline |
Create all intermediate directories and the final directory.
A successful call to this method with false returned indicates that the directories existed already.
filesystem_error | when there was an error attempting to create one or more of the directories |
|
inlineoverridevirtual |
|
inline |
Returns true if an item exits in the file system for the file URI.
|
inlinevirtual |
Get a non-recursive file iterator for this file (directory).
boost::filesystem::filesystem_error | if the current object is not a directory |
Reimplemented in ZipFile.
|
inline |
Get a file byte read resource for this file URI.
|
inline |
Get a file byte write resource for this file URI.
|
inline |
Get the underlying directory entry for this file URI.
|
inline |
Get the modified time of the file.
|
inline |
Get the parent directory of the file URI.
|
inline |
Create a new file representing the specified sub-directory of the file URI.
|
inline |
Get a file UTF-8 to UTF-32 write resource for this file URI.
|
inline |
Get a file UTF-8 to UTF-32 read resource for this file URI.
|
inlineoverridevirtualnoexcept |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inline |
Concatenate the supplied path fragment to the end of the path represented by the file.
|
inline |
Append a path component to the path represented by the file.
|
inline |
Append a path component to the path represented by the file.
|
inline |
Append a path component to the path represented by the file.
|
inline |
Append a sequence of path components to the path represented by the file.
T | the string type in the container |
Container | the container type |
container | the container containing the components to append |
|
inline |
Append a path component to the path represented by the file in place.
|
inline |
Append a path component to the path represented by the file in place.
|
inline |
Append a path component to the path represented by the file in place.
|
inline |
Return true if the current object is less than the supplied instance.
Copy assign the supplied file to this file.
Move assign the supplied file to this file.
|
inline |
Copy the supplied directory entry to this file.
|
inline |
Copy the supplied file system path to this file.
|
inline |
Compare the supplied file to the current file.
|
inlineoverridevirtual |
|
inlinevirtual |
Get a recursive file iterator for this file (directory).
boost::filesystem::filesystem_error | if the current object is not a directory |
Reimplemented in ZipFile.
|
inlineoverridevirtual |
Get the relative path of the current object, compared to the supplied file.
|
inline |
Remove the file if it exists.
|
inlineoverridevirtual |
Resolve the relative or absolute path, in reference to the current URI.
If the supplied path contains a scheme prefix, the URI fromString function will be called to create a new unrelated URI instance.
This method will determine the base path to use by applying the following rules.
path | a relative or absolute path, or a full URI |
Implements Uri.
Reimplemented in ZipFile.
|
inline |
Get the size of the file if it exists or -1 if the file does not exist.
IOException | if there was an error when getting the file size |
|
inline |
Convert the file to an absolute path if it is relative, using the current working directory.
|
inlineoverridevirtual |
Get a string representing the raw URI.
This may or may not be the same as the string returned by toUriString().
Implements Uri.
|
inlinevirtual |
Get a string representing the raw URI.
This may or may not be the same as the string returned by toUriString().
Implements Uri.
|
inlineoverridevirtual |
Get a string representing the URI, complete with scheme.
Implements Uri.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
static |
The path separator character for the platform.