1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi"). 12 #include <c/stdio.hpp> 23 namespace fs = std::filesystem;
26 inline namespace fs_util
35 if constexpr(
is_same_type_<
string, decltype( path.u8string() )> )
37 return path.u8string();
41 $with( path.u8string() ) {
return string( _.begin(), _.end() ); }
50 const auto woptions = wstring( options, options + strlen( options ) );
51 return _wfopen( path.wstring().c_str(), woptions.c_str() );
53 return fopen( path.string().c_str(), options );
73 {
return exchange( m_file,
nullptr ); }
77 if( m_file ) { fclose( m_file ); }
80 C_file( tag::Read,
const fs::path& path ):
89 C_file( tag::Write,
const fs::path& path ):
98 C_file( tag::Append,
const fs::path& path ):
Some_type * P_
Creates a raw pointer type.
is_base_and_derived_, is_same_type_, is_a_, is_const_, is_class_, is_fixed_point_,...
auto hopefully(const Truth condition) -> Truth
auto file_pointer() const -> P_< FILE >
Enable_if_ is just more readable than enable_if_t.
C_str for char const*; Wide_c_str for wchar_t const*; and Mutable_c_str and Mutable_wide_c_str as dit...
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
C_file(tag::Append, const fs::path &path)
$define_tag(NAME) defines NAME as a ~unique pointer type in namespace tag.
auto utf8_from(const Fs_path &path) -> string
auto release() -> P_< FILE >
auto quoted(const string_view &sv) -> string
C_file(tag::Write, const fs::path &path)
auto open_c_file(const fs::path &path, const C_str options) -> P_< FILE >
std::enable_if_t< condition, Result > Enable_if_
Just more readable than enable_if_t.
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...
C_file(tag::Read, const fs::path &path)
constexpr Truth is_same_type_