Create a temporary DIRECTORY

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
JohnD
Earned some good credits
Earned some good credits
Posts: 118
Joined: Fri Nov 21, 2008 2:18 pm

Create a temporary DIRECTORY

Post by JohnD » Fri Feb 10, 2012 10:02 am

I have a use-case where my app will spit out a large number of temp-files, and I want to create a new dir for these files each time, under the standard system temp dir. Is there any directory equivalent to wxFileName::CreateTempFileName, and if not what would be the simplest/recommended way? I don't want to name the directory myself, I prefer to have it named for me so I can avoid finding a unique name.

Bill87
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Nov 04, 2011 6:34 am

Re: Create a temporary DIRECTORY

Post by Bill87 » Fri Feb 10, 2012 10:40 am

You could do something like this?

Code: Select all

wxMilliClock_t now = wxGetLocalTimeMillis();

wxFileName::Mkdir(wxFileName::GetTempDir().Append(wxString::Format(wxT("\\prefix_%lu"), now)));

JohnD
Earned some good credits
Earned some good credits
Posts: 118
Joined: Fri Nov 21, 2008 2:18 pm

Re: Create a temporary DIRECTORY

Post by JohnD » Fri Feb 10, 2012 10:56 am

That's what I do right now (or similar using timestamp) in the absence of a helper method. I also wondered about creating a temp file with automatic name and then replacing it with a directory of the same name, but it seems a bit hacky :)

Post Reply