OT: 64 bit file

Discussion in 'C++' started by Chameleon, Jan 13, 2007.

  1. Chameleon

    Chameleon Guest

    How can I handle files with size bigger than 32-bits in a 32 bit machine?

    I believe there is no way with std c/c++.

    Is there a cross-platform library out there?

    Thanks
     
    Chameleon, Jan 13, 2007
    #1
    1. Advertising

  2. Chameleon

    Greg Guest

    Chameleon wrote:
    > How can I handle files with size bigger than 32-bits in a 32 bit machine?


    The size of a machine register does not necessarily place an upper
    limit on the size of an integer type for that architecture. For
    example, a 64-bit value might be stored in two 32-bit two registers, or
    be kept in memory. And the fact that a hard drive with less than 4GB is
    considered tiny today, a 32-bit computer has no choice but to be able
    to represent greater-than-32 bit file offsets somehow - if it wants to
    read files from a hard disk.

    > I believe there is no way with std c/c++.


    C and C++ declare typedefs to represent various sized types for their
    interfaces: size_t, fpos_t, streamoffset_t and others. So, assuming the
    interfaces on your machine have kept up with the times, I doubt there
    will be a problem writing a program to read and write large files.

    > Is there a cross-platform library out there?


    I would first consult at the standard interfaces files in your
    environment, starting with stdio.h, before concluding that some other
    solution is needed.

    Greg
     
    Greg, Jan 14, 2007
    #2
    1. Advertising

  3. Chameleon

    Bo Persson Guest

    Re: 64 bit file

    Chameleon wrote:
    > How can I handle files with size bigger than 32-bits in a 32 bit
    > machine?


    It depends on waht you mean by 'handle'.

    >
    > I believe there is no way with std c/c++.


    Nothing stops you from sequentially reading and writing files as large as
    the OS permits.

    There might be a problem if you want to do seeks on distances larger than
    what can be represented by a long. The general problem is how to represent
    values larger than the largest integer type.

    On some systems, the long type is 32 bit wide even for 64 bit
    implementations of the compiler.

    >
    > Is there a cross-platform library out there?


    Can't easily be, as it depends on the size of the largest integer type. In
    standard C++ that is type long, which has no given size.


    Bo Persson
     
    Bo Persson, Jan 14, 2007
    #3
  4. Chameleon

    Tim Slattery Guest

    Chameleon <> wrote:

    >How can I handle files with size bigger than 32-bits in a 32 bit machine?


    >I believe there is no way with std c/c++.


    >Is there a cross-platform library out there?


    First, what do you mean by "files with size bigger than 32-bits"? Do
    you mean files longer than 2**32 bytes? Your ability to read such a
    file will depend on operating system facilities. For example: 32-bit
    Windows XP implements the NTFS file system, which allows files to be
    *much* larger than 2**32 bytes. There are various API functions in
    WinXP to allow programmers to handle huge files.

    Also, you might want to check the Boost filesystem library
    (www.boosts.org). If eventually uses OS-specific facilities to read
    large files, but it becomes pretty transparent to you.

    --
    Tim Slattery

    http://members.cox.net/slatteryt
     
    Tim Slattery, Jan 16, 2007
    #4
  5. In message <>, Tim Slattery
    <> writes
    >Chameleon <> wrote:
    >
    >>How can I handle files with size bigger than 32-bits in a 32 bit machine?

    >
    >>I believe there is no way with std c/c++.

    >
    >>Is there a cross-platform library out there?

    >
    >First, what do you mean by "files with size bigger than 32-bits"? Do
    >you mean files longer than 2**32 bytes? Your ability to read such a
    >file will depend on operating system facilities. For example: 32-bit
    >Windows XP implements the NTFS file system, which allows files to be
    >*much* larger than 2**32 bytes. There are various API functions in
    >WinXP to allow programmers to handle huge files.
    >
    >Also, you might want to check the Boost filesystem library
    >(www.boosts.org).


    http://www.boost.org

    >If eventually uses OS-specific facilities to read
    >large files, but it becomes pretty transparent to you.


    The aim of the Boost filesystem library is to provide portable ways to
    access files by name, regardless of system-specific naming conventions.
    It provides replacements of the standard filestream classes with
    constructors and members which take filestream::path arguments instead
    of const char * to represent file names.

    For actually reading and writing the files it simply delegates to the
    standard filestream classes, so in that respect it's no more or less
    OS-specific, and no better at handling large files, than the standard
    library.

    --
    Richard Herring
     
    Richard Herring, Jan 18, 2007
    #5
  6. In message <>, Greg
    <> writes
    >Chameleon wrote:
    >> How can I handle files with size bigger than 32-bits in a 32 bit machine?

    >
    >The size of a machine register does not necessarily place an upper
    >limit on the size of an integer type for that architecture. For
    >example, a 64-bit value might be stored in two 32-bit two registers, or
    >be kept in memory. And the fact that a hard drive with less than 4GB is
    >considered tiny today, a 32-bit computer has no choice but to be able
    >to represent greater-than-32 bit file offsets somehow - if it wants to
    >read files from a hard disk.
    >
    >> I believe there is no way with std c/c++.

    >
    >C and C++ declare typedefs to represent various sized types for their
    >interfaces: size_t, fpos_t, streamoffset_t and others. So, assuming the
    >interfaces on your machine have kept up with the times, I doubt there
    >will be a problem writing a program to read and write large files.


    I wouldn't be so sure. For instance, Visual Studio 2005 only seems to
    define 64-bit streamoff and streampos types when compiling for a 64-bit
    target platform. That's not much use on a 32-bit platform with 64-bit
    file sizes.
    >
    >> Is there a cross-platform library out there?

    >
    >I would first consult at the standard interfaces files in your
    >environment, starting with stdio.h,


    .... where the same compiler uses 'long' as the argument type for fseek()
    etc. To use longer offsets, it provides extensions like _fseeki64().


    >before concluding that some other
    >solution is needed.
    >


    --
    Richard Herring
     
    Richard Herring, Jan 18, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,776
    Timothy Bendfelt
    Jan 19, 2007
  2. Replies:
    9
    Views:
    990
    Juha Nieminen
    Aug 22, 2007
  3. Alfred Bovin

    Reading file bit by bit

    Alfred Bovin, Jun 7, 2010, in forum: Python
    Replies:
    14
    Views:
    607
    Martin
    Jun 8, 2010
  4. Sniper Abandon
    Replies:
    3
    Views:
    239
    Robert Klemme
    Nov 19, 2009
  5. Jeff.M
    Replies:
    6
    Views:
    183
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page