146 lines
5.1 KiB
Markdown
146 lines
5.1 KiB
Markdown
[depr.filesystems]
|
||
|
||
# Annex D (normative) Compatibility features [[depr]](./#depr)
|
||
|
||
## D.22 Deprecated file systems [depr.filesystems]
|
||
|
||
### [D.22.1](#depr.fs.path.factory) Deprecated filesystem path factory functions [[depr.fs.path.factory]](depr.fs.path.factory)
|
||
|
||
[1](#depr.fs.path.factory-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L793)
|
||
|
||
The header [<filesystem>](fs.filesystem.syn#header:%3cfilesystem%3e "31.12.4 Header <filesystem> synopsis [fs.filesystem.syn]") has the following additions:
|
||
|
||
[ð](#lib:u8path)
|
||
|
||
`template<class Source>
|
||
path u8path(const Source& source);
|
||
template<class InputIterator>
|
||
path u8path(InputIterator first, InputIterator last);
|
||
`
|
||
|
||
[2](#depr.fs.path.factory-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L804)
|
||
|
||
*Mandates*: The value type of Source and InputIterator ischar or char8_t[.](#depr.fs.path.factory-2.sentence-1)
|
||
|
||
[3](#depr.fs.path.factory-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L809)
|
||
|
||
*Preconditions*: The source and [first, last) sequences are UTF-8 encoded[.](#depr.fs.path.factory-3.sentence-1)
|
||
|
||
Source meets the requirements specified in [[fs.path.req]](fs.path.req "31.12.6.4 Requirements")[.](#depr.fs.path.factory-3.sentence-2)
|
||
|
||
[4](#depr.fs.path.factory-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L814)
|
||
|
||
*Returns*:
|
||
|
||
- [(4.1)](#depr.fs.path.factory-4.1)
|
||
|
||
If path::value_type is char and the current native
|
||
narrow encoding ([[fs.path.type.cvt]](fs.path.type.cvt "31.12.6.3.2 Type and encoding conversions")) is UTF-8,
|
||
return path(source) or path(first, last);
|
||
otherwise,
|
||
|
||
- [(4.2)](#depr.fs.path.factory-4.2)
|
||
|
||
if path::value_type is wchar_t and the
|
||
native wide encoding is UTF-16, or
|
||
if path::value_type is char16_t or char32_t,
|
||
convert source or [first, last)
|
||
to a temporary, tmp, of type path::string_type and
|
||
return path(tmp);
|
||
otherwise,
|
||
|
||
- [(4.3)](#depr.fs.path.factory-4.3)
|
||
|
||
convert source or [first, last)
|
||
to a temporary, tmp, of type u32string and
|
||
return path(tmp)[.](#depr.fs.path.factory-4.sentence-1)
|
||
|
||
[5](#depr.fs.path.factory-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L833)
|
||
|
||
*Remarks*: Argument format conversion ([[fs.path.fmt.cvt]](fs.path.fmt.cvt "31.12.6.3.1 Argument format conversions")) applies to the
|
||
arguments for these functions[.](#depr.fs.path.factory-5.sentence-1)
|
||
|
||
How Unicode encoding conversions are performed is
|
||
unspecified[.](#depr.fs.path.factory-5.sentence-2)
|
||
|
||
[6](#depr.fs.path.factory-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L839)
|
||
|
||
[*Example [1](#depr.fs.path.factory-example-1)*:
|
||
|
||
A string is to be read from a database that is encoded in UTF-8, and used
|
||
to create a directory using the native encoding for filenames:namespace fs = std::filesystem;
|
||
std::string utf8_string = read_utf8_data();
|
||
fs::create_directory(fs::u8path(utf8_string));
|
||
|
||
For POSIX-based operating systems with the native narrow encoding set
|
||
to UTF-8, no encoding or type conversion occurs[.](#depr.fs.path.factory-6.sentence-2)
|
||
|
||
For POSIX-based operating systems with the native narrow encoding not
|
||
set to UTF-8, a conversion to UTF-32 occurs, followed by a conversion to the
|
||
current native narrow encoding[.](#depr.fs.path.factory-6.sentence-3)
|
||
|
||
Some Unicode characters may have no native character
|
||
set representation[.](#depr.fs.path.factory-6.sentence-4)
|
||
|
||
For Windows-based operating systems a conversion from UTF-8 to
|
||
UTF-16 occurs[.](#depr.fs.path.factory-6.sentence-5)
|
||
|
||
â *end example*]
|
||
|
||
[*Note [1](#depr.fs.path.factory-note-1)*:
|
||
|
||
The example above is representative of
|
||
a historical use of filesystem::u8path[.](#depr.fs.path.factory-6.sentence-6)
|
||
|
||
To indicate a UTF-8 encoding,
|
||
passing a std::u8string to path's constructor is preferred
|
||
as it is consistent with path's handling of other encodings[.](#depr.fs.path.factory-6.sentence-7)
|
||
|
||
â *end note*]
|
||
|
||
### [D.22.2](#depr.fs.path.obs) Deprecated filesystem path format observers [[depr.fs.path.obs]](depr.fs.path.obs)
|
||
|
||
[1](#depr.fs.path.obs-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L872)
|
||
|
||
The following members are declared in addition to those members
|
||
specified in [[fs.path.member]](fs.path.member "31.12.6.5 Members"):
|
||
|
||
namespace std::filesystem {class path {public: std::string string() const;
|
||
std::string generic_string() const; };}
|
||
|
||
[ð](#lib:string,path)
|
||
|
||
`std::string string() const;
|
||
`
|
||
|
||
[2](#depr.fs.path.obs-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L892)
|
||
|
||
*Returns*: system_encoded_string()[.](#depr.fs.path.obs-2.sentence-1)
|
||
|
||
[ð](#lib:generic_string,path)
|
||
|
||
`std::string generic_string() const;
|
||
`
|
||
|
||
[3](#depr.fs.path.obs-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/future.tex#L903)
|
||
|
||
*Returns*: generic_system_encoded_string()[.](#depr.fs.path.obs-3.sentence-1)
|