4.4.1
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
fcppt.filesystem

Description

Helper functions for std::filesystem.

Link to ${fcppt_filesystem_TARGET}, or to fcppt_filesystem_interface if you only need the headers.

Classes

class  fcppt::filesystem::directory_range
 A range for directory iterators. More...
 
class  fcppt::filesystem::recursive_directory_range
 A range for recursive directory iterators. More...
 

Typedefs

using fcppt::filesystem::optional_size = fcppt::optional::object< std::uintmax_t >
 Optional size.
 

Functions

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::optional_error_code fcppt::filesystem::create_directories_recursive (std::filesystem::path const &path)
 Tries to creates directories recursively.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::optional_error_code fcppt::filesystem::create_directory (std::filesystem::path const &path)
 Tries to create a directory.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::extension (std::filesystem::path const &path)
 Returns the extension of a path as an fcppt::string.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::extension_without_dot (std::filesystem::path const &path)
 Returns the extension of a path as an fcppt::string without the dot.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::filesystem::optional_size fcppt::filesystem::file_size (std::filesystem::path const &path)
 Returns the size of a file.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::either::object< std::error_code, fcppt::filesystem::directory_rangefcppt::filesystem::make_directory_range (std::filesystem::path const &, std::filesystem::directory_options)
 Creates a directory range.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::either::object< std::error_code, fcppt::filesystem::recursive_directory_rangefcppt::filesystem::make_recursive_directory_range (std::filesystem::path const &, std::filesystem::directory_options)
 Creates a recursive directory range.
 
template<typename Stream >
fcppt::optional::object< Stream > fcppt::filesystem::open (std::filesystem::path const &_path, std::ios_base::openmode const _openmode)
 Opens a file, returning an optional.
 
template<typename Stream , typename Exception = fcppt::exception>
Stream fcppt::filesystem::open_exn (std::filesystem::path const &_path, std::ios_base::openmode const _openmode)
 Opens a file, throwing an exception on failure.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::path_to_string (std::filesystem::path const &path)
 Turns a path into an fcppt::string.
 
FCPPT_FILESYSTEM_DETAIL_SYMBOL std::filesystem::path fcppt::filesystem::remove_extension (std::filesystem::path path)
 Removes the extension from a path.
 

Typedef Documentation

◆ optional_size

Optional size.

Function Documentation

◆ create_directories_recursive()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::optional_error_code fcppt::filesystem::create_directories_recursive ( std::filesystem::path const &  path)

Tries to creates directories recursively.

Tries to create each nonexistant sub directory of path.

◆ create_directory()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::optional_error_code fcppt::filesystem::create_directory ( std::filesystem::path const &  path)

Tries to create a directory.

Tries to create the last component of path as a directory.

◆ extension()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::extension ( std::filesystem::path const &  path)

Returns the extension of a path as an fcppt::string.

Returns
The extension as an fcppt::string. If there is no extension, the string will be empty.

◆ extension_without_dot()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::extension_without_dot ( std::filesystem::path const &  path)

Returns the extension of a path as an fcppt::string without the dot.

Returns
The extension as an fcppt::string without the dot. If there is no extension, the string will be empty.

◆ file_size()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::filesystem::optional_size fcppt::filesystem::file_size ( std::filesystem::path const &  path)

Returns the size of a file.

Returns the size of path if it exists and its size can be obtained, otherwise returns the empty optional.

◆ make_directory_range()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::either::object< std::error_code, fcppt::filesystem::directory_range > fcppt::filesystem::make_directory_range ( std::filesystem::path const &  ,
std::filesystem::directory_options   
)

Creates a directory range.

◆ make_recursive_directory_range()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::either::object< std::error_code, fcppt::filesystem::recursive_directory_range > fcppt::filesystem::make_recursive_directory_range ( std::filesystem::path const &  ,
std::filesystem::directory_options   
)

Creates a recursive directory range.

◆ open()

template<typename Stream >
fcppt::optional::object< Stream > fcppt::filesystem::open ( std::filesystem::path const &  _path,
std::ios_base::openmode const  _openmode 
)

Opens a file, returning an optional.

Tries to open _path with _openmode and returns an empty optional on failure.

Template Parameters
StreamMust be a std::{basic_ifstream,basic_ofstream,basic_fstream}.

◆ open_exn()

template<typename Stream , typename Exception = fcppt::exception>
Stream fcppt::filesystem::open_exn ( std::filesystem::path const &  _path,
std::ios_base::openmode const  _openmode 
)

Opens a file, throwing an exception on failure.

Tries to open _path with _openmode and throw an exception on failure.

Template Parameters
StreamMust be a std::{basic_ifstream,basic_ofstream,basic_fstream}.
ExceptionMust be constructible from fcppt::string.

◆ path_to_string()

FCPPT_FILESYSTEM_DETAIL_SYMBOL fcppt::string fcppt::filesystem::path_to_string ( std::filesystem::path const &  path)

Turns a path into an fcppt::string.

Turns path into an fcppt::string.

◆ remove_extension()

FCPPT_FILESYSTEM_DETAIL_SYMBOL std::filesystem::path fcppt::filesystem::remove_extension ( std::filesystem::path  path)

Removes the extension from a path.

Removes the extension (inluding the dot) from path if it has any.

Parameters
pathThe path to remove the extension from
Returns
A new path with the extension removed