• Advertisement
Sign in to follow this  

Handling Large Files 4gb

This topic is 3585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone have experience handling large files(4gb and above) using C++ and the Win32 API? I'm using stuff like fgetpos and the likes, but the functions when opening a 9gb file seem to be returning a filesize of 0, without triggering an error. Does anyone have experience with this?

Share this post


Link to post
Share on other sites
Advertisement
You'll probably need to use native API functions to manipulate large files. For example, to get the file pointer you should use SetFilePointerEx() with a move method of FILE_CURRENT and a distance of zero.

Share this post


Link to post
Share on other sites
There's 64-bit versions of some of the CRT functions, although it's visual studio specific. _filelengthi64 might be what you need.

As far as I know there's no 64-bit version of fgetpos or ftell though. If you need them, you might need to switch to raw Win32 file handles (I don't know if the C++ iostreams library copes with files over 4GB).

Share this post


Link to post
Share on other sites
ah! gotcha! so it seems I need to move away with low-level file handling and just switch over to Window's file handling functions.

This page seems to have all the functions I'll need.

Thanks a bunch guys, that was enough to unstuck me.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement