Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > get temp directory

Reply
Thread Tools

get temp directory

 
 
Alberto Bignotti
Guest
Posts: n/a
 
      02-28-2008
How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      02-28-2008
Alberto Bignotti wrote:
> How to get user temporany directory from c++ function?
>
> example:
>
> string myTempDir = getTempDir();
>
> now myTempDir contains 'c:\tmp'
>
> is there a portable function?


No, there is no portable function because there is no portable
notion of "user temporary directory". However, you could try
'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
[rob desbois]
Guest
Posts: n/a
 
      02-28-2008
On Feb 28, 4:00 pm, "Alberto Bignotti" <(E-Mail Removed)>
wrote:
> How to get user temporany directory from c++ function?
>
> example:
>
> string myTempDir = getTempDir();
>
> now myTempDir contains 'c:\tmp'
>
> is there a portable function?


Alberto,

As Victor says c++ has no notion of a temporary file directory, but if
you just want to create a temporary file the the C library's stdio
header provides the function tmpfile():
http://www.cplusplus.com/reference/c...o/tmpfile.html

HTH,
--rob
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      02-28-2008
On Feb 28, 5:03 pm, "Victor Bazarov" <(E-Mail Removed)> wrote:
> Alberto Bignotti wrote:
> > How to get user temporany directory from c++ function?


> > example:


> > string myTempDir = getTempDir();


> > now myTempDir contains 'c:\tmp'


> > is there a portable function?


> No, there is no portable function because there is no portable
> notion of "user temporary directory". However, you could try
> 'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.


TMPDIR is what Posix recommends, I think.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.36 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work? PerlFAQ Server Perl Misc 0 04-26-2011 10:00 AM
Get user Temp directory Najd C++ 6 04-17-2006 09:42 AM
How to initialize member reference with temp object and delete the temp object when the destructor is called? PengYu.UT@gmail.com C++ 2 05-09-2005 05:48 PM
File::Temp: opening the temp. file in "r+" mode? Also "man in the middle" A. Farber Perl Misc 3 03-03-2004 12:42 PM
Temp Internet and temp files now in winnt directory w2k pro Bibble Bobble Computer Support 1 11-27-2003 06:14 PM



Advertisments