Decrease external file size

AUser1
2008-04-24
2013-04-25
  • AUser1

    AUser1 - 2008-04-24

    Hello,

    I have recently started to use STXXL in a large datset maniuplation program  - so far it has been great, however I have a quick question.

    Is there any way to programatically return the STXXL external memory file back to its original requested size when the program quits? When I maniupulate data structures that are larger than the user's .stxxl file has allocated for external storage, STXXL (quite nicely so) will increase the amount of space allocated. However this can pose a problem when the program quits if there has been processing of large quantities of data in use, as it eats through HDD space. Is there any way to resize or zero the file at the end of the program?

    One possibility is to simply truncate the file at the end manually using an fstream, but this seems messy and it cannot restore the file to its correct size - only zero it. Is there a good way to do this?

    Thankyou

     
    • Nobody/Anonymous

      Hi,

      so far there is no special way to do it from Stxxl. I suggest you to do it manually using the "ftruncate" function instead of fstream.

      NAME
             ftruncate - truncate a file to a specified length

      SYNOPSIS
             #include <unistd.h>

             int ftruncate(int fildes, off_t length);

      Roman

       

Log in to post a comment.