Espacios de nombres
Variantes
Acciones

std::tmpnam

De cppreference.com
< cpp‎ | io‎ | c
 
 
 
 
Definido en el archivo de encabezado <cstdio>
char* tmpnam(char* filename );
Crea un nombre de archivo único que no nombre un archivo existente en la actualidad, y la almacena en la cadena de caracteres apuntada por filename. La función es capaz de generar hasta TMP_MAX de nombres de archivo único, pero algunos o todos ellos pueden estar ya en uso, y por lo tanto no los valores adecuados de retorno .
Original:
Creates an unique filename that does not name a currently existing file, and stores it in the character string pointed to by filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may already be in use, and thus not suitable return values.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar]Parámetros

filename -
puntero a la matriz de caracteres capaz de contener los bytes menos L_tmpnam, para ser usados ​​como un tampón resultado. Si NULL se pasa, un puntero a un buffer estático interno se devuelve .
Original:
pointer to the character array capable of holding at least L_tmpnam bytes, to be used as a result buffer. If NULL is passed, a pointer to an internal static buffer is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Valor de retorno

filename si filename no era NULL. De lo contrario un puntero a un buffer estático interno se devuelve. Si no hay ningún nombre de archivo adecuado puede ser generado, NULL se devuelve .
Original:
filename if filename was not NULL. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, NULL is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Notas

Cuando se invoca con el argumento de puntero nulo, esta función modifica un objeto global. Si otro subproceso llama std::tmpnam con el argumento de puntero nulo al mismo tiempo, el comportamiento es indefinido debido a una raza datos .
Original:
When called with null pointer argument, this function modifies a global object. If another thread calls std::tmpnam with null pointer argument at the same time, the behavior is undefined due to a data race.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Aunque los nombres generados por std::tmpnam son difíciles de adivinar, es posible que un archivo con el mismo nombre creado por otro proceso entre los rendimientos std::tmpnam momento y el momento este programa intenta utilizar el nombre devuelto para crear un archivo. El std::tmpfile función estándar y la función POSIX mkstemp no tienen este problema .
Original:
Although the names generated by std::tmpnam are difficult to guess, it is possible that a file with that name is created by another process between the moment std::tmpnam returns and the moment this program attempts to use the returned name to create a file. The standard function std::tmpfile and the POSIX function mkstemp do not have this problem.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Ejemplo

#include <iostream>#include <cstdio>#include <string>int main(){std::string name1 = std::tmpnam(nullptr);std::cout<<"temporary file name: "<< name1 <<'\n';   char name2[L_tmpnam];if(std::tmpnam(name2))std::cout<<"temporary file name: "<< name2 <<'\n';}

Posible salida:

temporary file name: /tmp/fileDjwifs temporary file name: /tmp/fileEv2bfW

[editar]Ver también

crea y abre un temporal, auto-eliminación de archivos
Original:
creates and opens a temporary, auto-removing file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(función)[editar]
close