Linked Questions
16 questions linked to/from How to create a temporary text file in C++?
17 votes
6 answers
34k views
How to create a temporary directory in C++?
I'm writing a function in C++ which creates a temporary directory. Such function should be as most portable as possible, e.g. it should work under linux, mac and win32 environments. How do I achieve ...
25 votes
2 answers
22k views
What is an anonymous inode in Linux?
I made a google search about "anonymous inode" and it seems it's related to epoll ... but what actually is it?
32 votes
2 answers
12k views
What is the C++17 equivalent to boost::filesystem::unique_path()?
std::filesystem on C++17, and std::experimental::filesystem for many pre-C++17 compilers, are based on boost::filesystem and almost all of it is obvious to port to the newer std. But I see no std::...
11 votes
7 answers
9k views
How can I create a temporary file for writing in C++ on a Linux platform?
In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing? The filename should be as unique as possible, so that another process using the same ...
12 votes
1 answer
20k views
warning: the use of `tmpnam' is dangerous, better use `mkstemp' [duplicate]
(Note: This is not a duplicate question) I'm using the libc function tmpnam, and getting the following warning: warning: the use of 'tmpnam' is dangerous, better use 'mkstemp' My question isn't "...
3 votes
5 answers
4k views
tempnam equivalent in C++
I need to generate random names which I'll be using to create temporary files in a directory. Currently I am using C standard function tempnam() for this. My code is in C++ and would like to use C++ ...
3 votes
2 answers
3k views
Many ways to create a Temporary file: what is the situation behind each method?
My C++ winAPI application has a need to create a temporary file prior to uploading the file to a server. So I have searched ways to create a temporary file & found there are many ways to do this. ...
8 votes
1 answer
8k views
How can I get the temporary filename by using the tmpfile () [duplicate]
tmpfile () functions says that: The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally. If the program terminates abnormally, ...
0 votes
2 answers
2k views
Temporary files & folders on Windows
Emulating multithreading by loading a DLL multiple times (it's designed for this). Since LoadLibrary() doesn't really allow it, the DLL copies itself into a temporary file, via GetTempPath() and ...
1 vote
2 answers
2k views
mkstemp() implementation for Windows to write temporary files
I want to create temporary files in given temporary directory path in Windows through C++. mktemp() does the required job, but it only creates 26 unique files. mkstemp() is working fine in Linux but ...
13 votes
3 answers
2k views
How can I safely and portably create and use a temporary file with C++
I'm writing a library. In one of my unit tests, I want to create a temporary file (possibly using its path rather than its handle), make some library calls involving that file, and delete the file on ...
-1 votes
1 answer
941 views
Unable to create a temporary file on Windows in C++ using tmpfnam
I am trying to create a temporary file in my C++ program by calling the tmpfnam function to get the temporary file name and using that to create the file for writing, but my code is unable to create ...
3 votes
1 answer
416 views
Temporary files in C++. tmpnam alternatives
I'm trying to get a temporary filename so I can use it in an argument to a child process. The child process will output to that file, then I'll open the file, read the contents, and delete the file. ...
0 votes
1 answer
435 views
Creating temporary files from native code in C++ in Android
I am working on an Android project having native libraries in C++. Somewhere in the code, I encounter this line which tries to create a new file: namespace fs = boost::filesystem; dest_path = fs::...
0 votes
1 answer
277 views
How do I make a file of specific size in c++?
How do i make a dummy file? I'm using Visual C++ for a form and I need it to make a dummy file. I know how to use things like fstream to write to files but how can I do it so that I know the exact ...