Namespaces
Variants

std::experimental::filesystem:: temp_directory_path

From cppreference.net
Definido en el encabezado <experimental/filesystem>
path temp_directory_path ( ) ;
path temp_directory_path ( error_code & ec ) ;
(1) (filesystem TS)

Devuelve la ubicación del directorio adecuada para archivos temporales.

Contenidos

Parámetros

(ninguno)

Valor de retorno

Un directorio adecuado para archivos temporales. Se garantiza que la ruta existe y que es un directorio. La sobrecarga que toma el argumento error_code& devuelve una ruta vacía en caso de error.

Excepciones

The overload that does not take an error_code & parameter throws filesystem_error on underlying OS API errors, constructed with ruta a devolver 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 especificación:
noexcept

Notas

En sistemas POSIX, la ruta puede ser la especificada en las variables de entorno TMPDIR , TMP , TEMP , TEMPDIR , y, si ninguna de ellas está especificada, se devuelve la ruta "/tmp" .

En sistemas Windows, la ruta es típicamente la devuelta por GetTempPath .

Ejemplo

#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
    std::cout << "Temp directory is " << fs::temp_directory_path() << '\n';
}

Salida posible:

Temp directory is "C:\Windows\TEMP\"

Véase también

crea y abre un archivo temporal que se elimina automáticamente
(función)