[fs.op.current.path]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.op.current.path)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.current.path)

#### 31.12.13.12 Current path [fs.op.current.path]

[ð](#lib:current_path)

`path filesystem::current_path();
path filesystem::current_path(error_code& ec);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17743)

*Returns*: The absolute path of the current working directory,
 whose pathname in the native format is
 obtained as if by POSIX [getcwd](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html)[.](#1.sentence-1)

The signature with argument ec returns path() if an
 error occurs[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17751)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17755)

*Remarks*: The current working directory is the directory, associated
 with the process, that is used as the starting location in pathname resolution
 for relative paths[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17761)

[*Note [1](#note-1)*:

The current path as returned by many operating systems is a dangerous
 global variable and can be changed unexpectedly by third-party or system
 library functions, or by another thread[.](#4.sentence-1)

â *end note*]

[ð](#lib:current_path_)

`void filesystem::current_path(const path& p);
void filesystem::current_path(const path& p, error_code& ec) noexcept;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17776)

*Effects*: Establishes the postcondition, as if by POSIX [chdir](http://pubs.opengroup.org/onlinepubs/9699919799/functions/chdir.html)[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17780)

*Postconditions*: equivalent(p, current_path())[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17784)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17788)

[*Note [2](#note-2)*:

The current path for many operating systems is a dangerous
 global state and can be changed unexpectedly by third-party or system
 library functions, or by another thread[.](#8.sentence-1)

â *end note*]
