Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. getting 64 bit stream pos

getting 64 bit stream pos

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugging
4 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jon Hulatt
    wrote on last edited by
    #1

    I'm working with very large files and i need to be able to get a 64bit stream position. ofstream::tellp() returns a streampos, which according to msdn is typedef fpos<mbstate_t> streampos; Whatever i try and cast the result to, it's wrong for files over 4GB- it's being truncated at 32 bits. What is odd is that according to mssn, fpos stores a byte offset of type streamoff, and a conversion state of type T. streamoff (according to msdn) is a long in win32 and an __int64 in win64. I am building under win32 but the debugger shows the private _Fpos member of fpos to be of type __int64. So, irritatingly, the 64 bit value is there in the fpos (i can see in the debugger, it's correct) but i can't get the value out. Any ideas? there must be a way of getting a 64bit file pos in win32.

    using System.Beer;

    _ A 2 Replies Last reply
    0
    • J Jon Hulatt

      I'm working with very large files and i need to be able to get a 64bit stream position. ofstream::tellp() returns a streampos, which according to msdn is typedef fpos<mbstate_t> streampos; Whatever i try and cast the result to, it's wrong for files over 4GB- it's being truncated at 32 bits. What is odd is that according to mssn, fpos stores a byte offset of type streamoff, and a conversion state of type T. streamoff (according to msdn) is a long in win32 and an __int64 in win64. I am building under win32 but the debugger shows the private _Fpos member of fpos to be of type __int64. So, irritatingly, the 64 bit value is there in the fpos (i can see in the debugger, it's correct) but i can't get the value out. Any ideas? there must be a way of getting a 64bit file pos in win32.

      using System.Beer;

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      _ftelli64 can do that.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      1 Reply Last reply
      0
      • J Jon Hulatt

        I'm working with very large files and i need to be able to get a 64bit stream position. ofstream::tellp() returns a streampos, which according to msdn is typedef fpos<mbstate_t> streampos; Whatever i try and cast the result to, it's wrong for files over 4GB- it's being truncated at 32 bits. What is odd is that according to mssn, fpos stores a byte offset of type streamoff, and a conversion state of type T. streamoff (according to msdn) is a long in win32 and an __int64 in win64. I am building under win32 but the debugger shows the private _Fpos member of fpos to be of type __int64. So, irritatingly, the 64 bit value is there in the fpos (i can see in the debugger, it's correct) but i can't get the value out. Any ideas? there must be a way of getting a 64bit file pos in win32.

        using System.Beer;

        A Offline
        A Offline
        Aescleal
        wrote on last edited by
        #3

        What happens when you use the seekpos member of std::fstream::pos_type (i.e. the thing returned by tellp)? As far as I can tell that's a 64 bit value (long long on VC++ 2010). Not sure how standard that is as I don't deal with large files much. Cheers, Ash PS: Something like:

        std::fstream fs( ... );

        // More good stuff

        std::fstream::pos_type pt( fs.tellp() );
        fpos_t fpt( pt.seekpos() );

        EDIT: Looks like this is about as portable as a brick. According to the standard about all streampos has to do is support conversion to/from an int and be comparable with another streampos.

        modified on Tuesday, June 22, 2010 12:23 PM

        J 1 Reply Last reply
        0
        • A Aescleal

          What happens when you use the seekpos member of std::fstream::pos_type (i.e. the thing returned by tellp)? As far as I can tell that's a 64 bit value (long long on VC++ 2010). Not sure how standard that is as I don't deal with large files much. Cheers, Ash PS: Something like:

          std::fstream fs( ... );

          // More good stuff

          std::fstream::pos_type pt( fs.tellp() );
          fpos_t fpt( pt.seekpos() );

          EDIT: Looks like this is about as portable as a brick. According to the standard about all streampos has to do is support conversion to/from an int and be comparable with another streampos.

          modified on Tuesday, June 22, 2010 12:23 PM

          J Offline
          J Offline
          Jon Hulatt
          wrote on last edited by
          #4

          yeah, it's rubbish, isn't it. pos_type has an int64 member, but there's no operator overload to get that out -only an int.

          using System.Beer;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups