std::experi...ectory_path(3)
π std::experi...ectory_path(3) π
okay bestie, welcome to the C++ Standard Libary manual page for std::experi...ectory_path(3) β yes the title is literally truncated like that, and we are respectfully not fixing it π. This whole page is about std::experimental::filesystem::temp_directory_path, and its entire job is handing you a directory that's suitable for temporary files. Let's go π¦.
β¨ NAME β¨
std::experimental::filesystem::temp_directory_path - std::experimental::filesystem::temp_directory_path
πΈ Synopsis πΈ
Defined in header <experimental/filesystem>:
path temp_directory_path(); (1) (filesystem TS)
path temp_directory_path( error_code& ec );
Returns the directory location suitable for temporary files.
π Parameters π
(none) β literally none, bestie. Nothing to pass here.
π Return value π
A directory suitable for temporary files. The path is guaranteed to exist and to be a directory. The overload that takes error_code& argument returns an empty path on error.
π Exceptions π
The overload that does not take an error_code& parameter throws filesystem_error on underlying OS API errors, constructed with path to be returned as the first argument and the OS error code as the error code argument. std::bad_alloc may be thrown if memory allocation fails.
The overload taking an error_code& parameter sets it to the OS API error code if an OS API call fails, and executes ec.clear() if no errors occur. This overload has noexcept specification: noexcept.
π Notes π
On POSIX systems, the path may be the one specified in the environment variables TMPDIR, TMP, TEMP, TEMPDIR, and, if none of them are specified, the path "/tmp" is returned. π
On Windows systems, the path is typically the one returned by GetTempPath. πͺ
π Example π
// Run this code
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
std::cout << "Temp directory is " << fs::temp_directory_path() <<
'\n';
}
Possible output:
Temp directory is "C:\Windows\TEMP\"
π See also π
tmpfilecreates and opens a temporary, auto-removing file (function)
π·οΈ Categories π·οΈ
Noindexed pagesunconditionally noexcept
π Hidden categories π
Pages with unreviewed unconditional noexcept templatePages with unreviewed noexcept template
that's the whole vibe, bestie π this page came from http://cppreference.com, version 2024.06.10, and it's the std::experi...ectory_path(3) page. slay responsibly β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms