Handling Large Files 4gb

Started by
2 comments, last by Prozak 16 years, 1 month ago
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?
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.
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).
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.

This topic is closed to new replies.

Advertisement