xentara-utils v2.0.1
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::filesystem Namespace Reference

File systen tools. More...

Namespaces

namespace  path
 Filesystem path functionality.
 

Classes

class  StandardPathIterator
 An iterator that traverses all directories in a standard system search path. More...
 

Enumerations

enum class  StandardPath { Config , Data }
 Standard system search paths. More...
 

Functions

auto replace (const std::filesystem::path &oldPath, const std::filesystem::path &newPath) -> void
 Replaces one file with another, preserving the properties.
 
auto replace (const std::filesystem::path &oldPath, const std::filesystem::path &newPath, std::error_code &errorCode) noexcept -> void
 Replaces one file with another, preserving the properties.
 
auto begin (StandardPath path) -> StandardPathIterator
 Gets a begin iterator for a standard path.
 
auto end (StandardPath) -> std::default_sentinel_t
 Gets an end iterator for a standard path.
 
String Conversion
template<tools::CharType Char, typename CharTraits = std::char_traits<Char>, typename Allocator = std::allocator<Char>>
auto toBasicString (const std::filesystem::path &path, const Allocator &allocator=Allocator()) -> decltype(auto)
 Converts a path to a string.
 
auto toString (const std::filesystem::path &path) -> decltype(auto)
 Converts a path to a string of type char
 
auto toWString (const std::filesystem::path &path) -> decltype(auto)
 Converts a path to a string of type wchar_t
 
auto toU8String (const std::filesystem::path &path) -> decltype(auto)
 Converts a path to a string of type char8_t
 
auto toU16String (const std::filesystem::path &path) -> decltype(auto)
 Converts a path to a string of type char16_t
 
auto toU32String (const std::filesystem::path &path) -> decltype(auto)
 Converts a path to a string of type char32_t
 

Detailed Description

File systen tools.

This namespace contains facilities used for file system access in conjunbction with the std::filesystem namespace.

Enumeration Type Documentation

◆ StandardPath

Standard system search paths.

This iterator supplies freestanding [begin()](xentara::utils::windows::wmi::begin(StandardPath)) and [end()](xentara::utils::windows::wmi::end(StandardPath)) functions, so they can be used in range-based for loops to iterate over the directories in the path without manually creating a StandardPathIterator:

for (auto &&path : xentara::utils::filesystem::StandardPath::Data)
{
...
}
StandardPath
Standard system search paths.
Definition StandardPathIterator.hpp:27
@ Data
Search path for data files.
Definition Optional.hpp:20
Include file
#include <xentara/utils/filesystem/StandardPathIterator.hpp>
Enumerator
Config 

Search path for configuration files.

Data 

Search path for data files.

Function Documentation

◆ begin()

auto begin ( StandardPath  path) -> StandardPathIterator

Gets a begin iterator for a standard path.

This function enables the use of StandardPath in range-based for loops

Include file
#include <xentara/utils/filesystem/StandardPathIterator.hpp>
Parameters
pathThe type of path to iterate over
Returns
Returns a StandardPathIterator for the given standard path

◆ end()

Gets an end iterator for a standard path.

This function enables the use of StandardPath in range-based for loops

Include file
#include <xentara/utils/filesystem/StandardPathIterator.hpp>
Returns
The global default sentinel

◆ replace() [1/2]

auto xentara::utils::filesystem::replace ( const std::filesystem::path oldPath,
const std::filesystem::path newPath 
) -> void

Replaces one file with another, preserving the properties.

This function renames the file oldPath to newPath similar to std::filesystem::rename(). However, the file will inherit all properties, like creation time, access mode, etc., from an existing file already located at newPath.

Include file
#include <xentara/utils/filesystem/replace.hpp>
Parameters
oldPathThe current path of the file
newPathThe new path for the file. If there is already a file with this path, it is overwritten, and the new file assumes its properties.

◆ replace() [2/2]

auto xentara::utils::filesystem::replace ( const std::filesystem::path oldPath,
const std::filesystem::path newPath,
std::error_code errorCode 
) -> void
noexcept

Replaces one file with another, preserving the properties.

This function renames the file oldPath to newPath similar to std::filesystem::rename(). However, the file will inherit all properties, like creation time, access mode, etc., from an existing file already located at newPath.

Include file
#include <xentara/utils/filesystem/replace.hpp>
Parameters
oldPathThe current path of the file
newPathThe new path for the file. If there is already a file with this path, it is overwritten, and the new file assumes its properties.
errorCodeReceives the error code on error. On success, errorCode.clear() is called.

◆ toBasicString()

template<tools::CharType Char, typename CharTraits = std::char_traits<Char>, typename Allocator = std::allocator<Char>>
auto xentara::utils::filesystem::toBasicString ( const std::filesystem::path path,
const Allocator &  allocator = Allocator() 
) -> decltype(auto)

Converts a path to a string.

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
allocatorThe allocator to use for the returned string
Returns
A string of type std::basic_string<Char, CharTraits, Allocator> containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.

◆ toString()

auto xentara::utils::filesystem::toString ( const std::filesystem::path path) -> decltype(auto)

Converts a path to a string of type char

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
Returns
A string of type std::string containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.

◆ toU16String()

auto xentara::utils::filesystem::toU16String ( const std::filesystem::path path) -> decltype(auto)

Converts a path to a string of type char16_t

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
Returns
A string of type std::u16string containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.

◆ toU32String()

auto xentara::utils::filesystem::toU32String ( const std::filesystem::path path) -> decltype(auto)

Converts a path to a string of type char32_t

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
Returns
A string of type std::u32string containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.

◆ toU8String()

auto xentara::utils::filesystem::toU8String ( const std::filesystem::path path) -> decltype(auto)

Converts a path to a string of type char8_t

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
Returns
A string of type std::u8string containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.

◆ toWString()

auto xentara::utils::filesystem::toWString ( const std::filesystem::path path) -> decltype(auto)

Converts a path to a string of type wchar_t

This function converts the path to a human readable string. The string always uses the preperred path separator.

Include file
#include <xentara/utils/filesystem/toString.hpp>
Parameters
pathThe path
Returns
A string of type std::wstring containing the path. The string will be returned either by value, or by const reference, whichever is more efficient.