Solved

How do I create a temporary directory and later delete it?

Posted on 2008-10-23
3
861 Views
Last Modified: 2012-06-22
I have a zip file which I need to unzip into a directory and work on those files.

I need assistance in creating a temporary directory under the current working directory which will be deleted after the operation and this should be portable on windows and linux.
0
Comment
Question by:Cool-Guy
3 Comments
 
LVL 6

Accepted Solution

by:
Werrock earned 500 total points
ID: 22794037
Its a platform-dependent call so I would recommend you to check out the boost libraries at
http://www.boost.org/

More precisly, the filesystem library:
http://www.boost.org/doc/libs/1_36_0/libs/filesystem/doc/index.htm
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 22794252
standard C++ does not know how to create temporary directories. It can create temporary files though using tmpfile :

        http://www.cplusplus.com/reference/clibrary/cstdio/tmpfile.html

But that doesn't help you :)

There is a nice alternative : to use the system's temporary directory, which on POSIX compliant systems can be retrieved using the TMPDIR environment variable.
0
 

Author Closing Comment

by:Cool-Guy
ID: 31509540
Thanks for your time.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question