[#BloombergLP-bdls-FilesystemUtil-createTemporaryFile-03] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/FilesystemUtil.adoc[FilesystemUtil]::createTemporaryFile :relfileprefix: ../../../ :mrdocs: Create and open a new temporary file with a name based on `prefix`. == Synopsis Declared in `<bdls_filesystemutil.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static xref:BloombergLP/bdls/FilesystemUtil/FileDescriptor.adoc[FileDescriptor] createTemporaryFile( xref:bsl/string.adoc[bsl::string]* outPath, std::string_view const& prefix); ---- == Description Create and open a new file with a name constructed by appending an automatically‐generated suffix to the specified `prefix`, and return its file descriptor open for reading and writing. A return value of `k_INVALID_FD` indicates that no such file could be created; otherwise, the name of the file created is assigned to the specified `outPath`. The file is created with permissions restricted, as closely as possible, to the caller`s userid only. If the prefix is a relative path, the file is created relative to the process current directory. Responsibility for deleting the file is left to the caller. Note that on Posix systems, if `outPath` is unlinked immediately, the file will remain usable until its descriptor is closed. Note that files created on Microsoft Windows may receive default, not restricted permissions. == Return Value a valid `FileDescriptor` on success, or `k_INVALID_FD` otherwise == Parameters [cols="1,4"] |=== | Name| Description | *outPath* | receives the path of the created file | *prefix* | prefix of the generated file name |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#