Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: C++, storing temporary files.

  1. #11
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C++, storing temporary files.

    Quote Originally Posted by BkkBonanza View Post
    As mentioned, the tmpnam() function gives you more control as it doesn't force a delete when closed. You just use it to generate a unique name and then pass that as filename to open.

    Another way would be to generate the filename as a hash of the original video url - that way the same url would always map to the same filename. There are some very simple/fast hash functions that would work for that and it would fit into a cache scheme better too. eg. if you generate the filename and it already exists then you know it's been downloaded already, or if length is not correct then you know a resume d/l is needed.
    This could be exactly what I need. Thank you. I already use the youtube video ID as a unique name so I do not need a hash.
    Last edited by cgroza; June 11th, 2011 at 10:02 PM.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  2. #12
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C++, storing temporary files.

    Just found out that the temp folder can be obtained with P_tmpdir from stdio.h.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  3. #13
    Join Date
    Apr 2008
    Location
    Far, far away
    Beans
    2,148
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: C++, storing temporary files.

    Quote Originally Posted by cgroza View Post
    This could be exactly what I need. Thank you. I already use the youtube video ID as a unique name so I do not need a hash.
    Just prefix the video id with something unique to your app. eg. groza

    And if you want, when you start up remove anything, groza* if you want to be sure the tmp files are wiped.

  4. #14
    Join Date
    Mar 2006
    Beans
    837

    Re: C++, storing temporary files.

    Also if you're using a GUI toolkit like Gtk, then there are helper functions to find the Temp folder on every platform.

  5. #15
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C++, storing temporary files.

    Quote Originally Posted by SledgeHammer_999 View Post
    Also if you're using a GUI toolkit like Gtk, then there are helper functions to find the Temp folder on every platform.
    I am using wxWidgets. I will try to find that helper function.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  6. #16
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C++, storing temporary files.

    Quote Originally Posted by BkkBonanza View Post
    Just prefix the video id with something unique to your app. eg. groza

    And if you want, when you start up remove anything, groza* if you want to be sure the tmp files are wiped.
    Thanks for the tip.
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

  7. #17
    Join Date
    Sep 2009
    Location
    Canada, Montreal QC
    Beans
    1,809
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: C++, storing temporary files.

    Quote Originally Posted by SledgeHammer_999 View Post
    Also if you're using a GUI toolkit like Gtk, then there are helper functions to find the Temp folder on every platform.
    Got it!
    wxStandardPaths::GetTempDir()
    I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
    Freedom is measured in Stallmans.
    Projects: gEcrit

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •