get temp directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alberto Bignotti

    get temp directory

    How to get user temporany directory from c++ function?

    example:

    string myTempDir = getTempDir();

    now myTempDir contains 'c:\tmp'

    is there a portable function?


  • Victor Bazarov

    #2
    Re: get temp directory

    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


    Comment

    • [rob desbois]

      #3
      Re: get temp directory

      On Feb 28, 4:00 pm, "Alberto Bignotti" <a.bigno...@aba cogroup.com>
      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():


      HTH,
      --rob

      Comment

      • James Kanze

        #4
        Re: get temp directory

        On Feb 28, 5:03 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
        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:james.kan ze@gmail.com
        Conseils en informatique orientée objet/
        Beratung in objektorientier ter Datenverarbeitu ng
        9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

        Comment

        Working...