Skip to content

Commit eabcef8

Browse files
TylerMSFTTylerMSFT
authored andcommitted
fix github #4259
1 parent 087c48c commit eabcef8

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

docs/standard-library/path-class.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description: "Learn more about: path Class"
33
title: "path Class"
44
ms.date: 06/17/2022
55
f1_keywords: ["filesystem/std::experimental::filesystem::path"]
6-
ms.custom: devdivchpfy22
76
---
87

98
# `path` Class
@@ -63,7 +62,7 @@ class path;
6362
|[`is_absolute`](#is_absolute)|For Windows, the function returns `has_root_name() && has_root_directory()`. For POSIX, the function returns `has_root_directory()`.|
6463
|[`is_relative`](#is_relative)|Returns `!is_absolute()`.|
6564
|[`make_preferred`](#make_preferred)|Converts each separator to a `preferred_separator` as needed.|
66-
|[`native`](#native)|Returns `myname`.|
65+
|[`native`](#native)|Returns the native representation of the path.|
6766
|[`parent_path`](#parent_path)|Returns the parent path component of `myname`.|
6867
|[`preferred_separator`](#preferred_separator)|The constant object gives the preferred character for separating path components, depending on the host operating system. |
6968
|[`relative_path`](#relative_path)|Returns the relative path component of `myname`. |
@@ -436,12 +435,30 @@ path& make_preferred();
436435

437436
## <a name="native"></a> `path::native`
438437

439-
Returns `myname`.
438+
Get the native string representation of the path.
440439

441440
```cpp
442441
const string_type& native() const noexcept;
443442
```
444443

444+
### Remarks
445+
446+
The path is available in a portable generic format (see [`generic_string()`](#generic_string)). Or, you can get the native format of the path. This function returns the native string. On a POSIX system, the generic format and the native format are the same.
447+
448+
In the following example, tested on Windows 11, the generic path string is `c:/t/temp/temp.txt` and the native string is `c:\\t\\temp.txt`
449+
450+
```cpp
451+
// Compile with /std:c++17 or higher
452+
#include <filesystem>
453+
454+
int main()
455+
{
456+
std::filesystem::path p(R"(c:\t\temp.txt)");
457+
auto native = p.native(); // Windows: L"c:\\t\temp.txt"
458+
auto generic = p.generic_string(); // Windows: "c:/t/temp.txt"
459+
}
460+
```
461+
445462
## <a name="op_as"></a> `path::operator=`
446463

447464
Replaces the elements of the path with a copy of another path.

0 commit comments

Comments
 (0)