Menu

Large file support for par2cmdline in Linux

2004-03-17
2004-03-17
  • Nestal Wan Wai Ho

    The patch below will enable large file support in linux. Note that it must be compiled with -D_FILE_OFFSET_BITS=64 and -D_LARGEFILE_SOURCE

    enjoy.

    diff -rup /tmp/par2cmdline-0.3/diskfile.cpp /home/nestal/par2cmdline-0.3/diskfile.cpp
    --- /tmp/par2cmdline-0.3/diskfile.cpp    2003-05-27 02:01:14.000000000 +0800
    +++ /home/nestal/par2cmdline-0.3/diskfile.cpp    2004-03-17 12:50:32.000000000 +0800
    @@ -347,8 +347,8 @@ list<string>* DiskFile::FindFiles(string
    #else // !WIN32
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    -#define OffsetType long
    -#define MaxOffset 0x7fffffffL
    +#define OffsetType long long
    +#define MaxOffset 0x7fffffffffffffffLL
    #define LengthType unsigned int
    #define MaxLength 0xffffffffUL

    @@ -394,7 +394,7 @@ bool DiskFile::Create(string _filename,

       if (_filesize > 0)
       {
    -    if (fseek(file, (OffsetType)_filesize-1, SEEK_SET))
    +    if (fseeko(file, (OffsetType)_filesize-1, SEEK_SET))
         {
           fclose(file);
           file = 0;
    @@ -436,7 +436,7 @@ bool DiskFile::Write(u64 _offset, const
         }

    -    if (fseek(file, (OffsetType)_offset, SEEK_SET))
    +    if (fseeko(file, (OffsetType)_offset, SEEK_SET))
         {
           cerr << "Could not write " << (u64)length << " bytes to " << filename << " at offset " << _offset << endl;
           return false;
    @@ -508,7 +508,7 @@ bool DiskFile::Read(u64 _offset, void *b
         }

    -    if (fseek(file, (OffsetType)_offset, SEEK_SET))
    +    if (fseeko(file, (OffsetType)_offset, SEEK_SET))
         {
           cerr << "Could not read " << (u64)length << " bytes from " << filename << " at offset " << _offset << endl;
           return false;

     
    • Peter C

      Peter C - 2004-03-17

      Thanks for this, but I've already written equivalent code that should be a little more portable.

      I shall be releasing it as part of version 0.4 in the near future.

       
    • Nestal Wan Wai Ho

      I am looking forward to see it work in 0.4.
      Thanks for the help!

       

Log in to post a comment.