xentara-utils v1.0
Xentara utilities library
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. More...
 
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. More...
 
auto begin (StandardPath path) -> StandardPathIterator
 Gets a begin iterator for a standard path. More...
 
auto end (StandardPath) -> std::default_sentinel_t
 Gets an end iterator for a standard path. More...
 

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:

{
...
}
@ Data
Search path for data files.
Enumerator
Config 

Search path for configuration files.

Data 

Search path for data files.

Function Documentation

◆ begin()

auto xentara::utils::filesystem::begin ( StandardPath  path) -> StandardPathIterator

Gets a begin iterator for a standard path.

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

Parameters
pathThe type of path to iterate over
Returns
Returns a StandardPathIterator for the given standard path

◆ end()

auto xentara::utils::filesystem::end ( StandardPath  ) -> std::default_sentinel_t

Gets an end iterator for a standard path.

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

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.

Parameters
oldPathThe current path of the file
newPathThe new path for the file. There must already be an existing file at this path.

◆ 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.

Parameters
oldPathThe current path of the file
newPathThe new path for the file. There must already be an existing file at this path.
errorCodeReceives the error code on error. On success, errorCode.clear() is called.