OFSTRUCT file_data;
int file_handle = OpenFile(filename, &file_data, OF_READ);
Now, I was wondering how do I open just a part of that file, example from byte 200 to byte 300.
A example would be really appreciated.
Edited by - delbogun on October 16, 2001 6:47:11 AM
how do I load a part of a file?
I'm currently using these lines to open a file from disc:
You cant open just a part of a file, a files state is either opened or closed. Just open the file, and seek to the appropriate area, then read in the required amount of data.
ok, thanks
but if you have a file that is example 200 mb, does it take long time to open the file and then seek the area?
but if you have a file that is example 200 mb, does it take long time to open the file and then seek the area?
Opening a file is just basically getting the filepointer to point to the file, the file is not actually placed in memory until YOU read from the file. Opening a 2kb file is the same as opening a 200Mb file.
djsomers
djsomers
another question: how do I use _lseek?
example if I want to go to position 0x1A on a file, do I write this?
long pos = _lseek(file_handle,0x1A,SEEK_SET);
but then how do i use that information on _lread ?
MSDN doesn''t give me much information about that.
example if I want to go to position 0x1A on a file, do I write this?
long pos = _lseek(file_handle,0x1A,SEEK_SET);
but then how do i use that information on _lread ?
MSDN doesn''t give me much information about that.
Just use lread on the file_handle after the call to lseek. That''s because lseek has already advanced the file_handle to position 0x1A
i tried that once, but it didn''t seem to work... i have probably missed something, thanks anyway, i''ll try again later with another file
Here is the code that reads file from byte 200 to byte 300
char buffer[100];
HFILE hFile = _lopen(filename, OF_READ);
_llseek(hFile, 200, FILE_BEGIN);
_lread(hFile, buffer, sizeof(buffer));
char buffer[100];
HFILE hFile = _lopen(filename, OF_READ);
_llseek(hFile, 200, FILE_BEGIN);
_lread(hFile, buffer, sizeof(buffer));
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement