如何在Windows上查看超过4GB的kg()文件? [英] How can I seekg() files over 4GB on Windows?
问题描述
我在Windows 7,64位和NTFS。
我建立一个必须是32位的DLL。我有一个非常简单的例程,我想在C ++中实现。我正在读一个大文件:
unsigned long p;
ifstream source(file);
streampos pp(p);
source.seekg(pp);
对于超过4GB的文件,我尝试使用unsigned long long,但它不工作。
我做错了什么?我使用的是GNU GCC,是否可以试用MSVC Express 2008/2010?
更新:
$ b
似乎我的GCC有问题。现在我使用MSVC测试你的建议,它似乎是工作。 MSVC使用_int64表示streampos / streamoff对象,我稍后将使用GCC检查。
相对寻找,即使用 seekg
的双参数重载。
//开始寻找从头开始
source.seekg(some_pos,std :: ios :: beg);
//然后从那个位置寻找更多的东西
source.seekg(some_offset,std :: ios :: cur);
I am on Windows 7, 64bit and NTFS. I am building a DLL that must be 32 bit. I have a very simple routine that I'd like to implement in C++. I'm reading a large file using:
unsigned long p;
ifstream source(file);
streampos pp(p);
source.seekg(pp);
For files over 4GB I tried using unsigned long long but it's not working. What am I doing wrong? I'm using GNU GCC, would it be of any use trying MSVC Express 2008/2010?
Update:
There seems that something is wrong with my GCC. Right now I'm testing your proposals using MSVC and it seems that is working. MSVC uses an _int64 to represent streampos/streamoff objects, I will check later with GCC.
You may have to use a number of relative seeks instead, i.e. use the two-argument overload of seekg
.
// Start with seeking from the beginning
source.seekg(some_pos, std::ios::beg);
// Then seek some more from that position
source.seekg(some_offset, std::ios::cur);
这篇关于如何在Windows上查看超过4GB的kg()文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!