[fs.op.temp.dir.path]

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

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

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

#### 31.12.13.39 Temporary directory path [fs.op.temp.dir.path]

[ð](#lib:temp_directory_path)

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

[1](#1)

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

Let p be an unspecified directory path suitable for temporary files[.](#1.sentence-1)

[2](#2)

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

*Effects*: If exists(p) is false or is_directory(p) is false, an error is reported ([[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#L18780)

*Returns*: The path p[.](#3.sentence-1)

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

[4](#4)

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

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

[5](#5)

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

[*Example [1](#example-1)*:

For POSIX-based operating systems, an implementation might
 return the path
 supplied by the first environment variable found in the list TMPDIR, TMP, TEMP, TEMPDIR,
 or if none of these are found, "/tmp"[.](#5.sentence-1)

For Windows-based operating systems, an implementation might return the path
 reported by the Windows GetTempPath API function[.](#5.sentence-2)

â *end example*]
