std::experimental::filesystem:: temp_directory_path
From cppreference.net
<
cpp
|
experimental
|
fs
|
ヘッダーで定義
<experimental/filesystem>
|
||
|
path temp_directory_path
(
)
;
path temp_directory_path ( error_code & ec ) ; |
(1) | (filesystem TS) |
一時ファイルに適したディレクトリの場所を返します。
目次 |
パラメータ
(なし)
戻り値
一時ファイルに適したディレクトリ。このパスは存在することが保証されており、ディレクトリであることも保証されています。
error_code&
引数を取るオーバーロードは、エラー時に空のパスを返します。
例外
The overload that does not take an error_code & parameter throws filesystem_error on underlying OS API errors, constructed with 返されるパス 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
仕様:
noexcept
注記
POSIXシステムでは、パスは環境変数
TMPDIR
、
TMP
、
TEMP
、
TEMPDIR
で指定されたもの、あるいはそれらのいずれも指定されていない場合、
"/tmp"
が返されます。
Windowsシステムでは、パスは通常
GetTempPath
によって返されるものです。
例
このコードを実行
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { std::cout << "Temp directory is " << fs::temp_directory_path() << '\n'; }
出力例:
Temp directory is "C:\Windows\TEMP\"
関連項目
|
一時的で自動削除されるファイルを作成してオープンする
(関数) |