getting 64 bit stream pos
-
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;
-
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;
_ftelli64
can do that.«_Superman_»
I love work. It gives me something to do between weekends. -
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;
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
-
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
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;