Page 1 of 1

File Access

PostPosted: Sep 8, 2007 @ 4:28pm
by jonah
I am a little new to edgelib and c++ for that matter, so I wonder if one of you could help me with a little problem :

I have a edgelib PACK file that contain images and other resources. I can open the pack however I see only one method to get at the data

unsigned char *filemem;

ef.PackGetFileData(filemem, memsize, ctr);

from what I understand this loads the whole file into memory i.e. to "filemem" is this correct or am I wrong in my thinking?

If it does load the whole file then is it possible to only load specific parts of the file only and to use some sort of Seek command to goto an explicit position in the file?
The file I am loading is a dictionary and I need only to goto specific words in the file I don't want to load the whole file.

I know if I don't load the file from a pack file I can use the Seek command in ClassEFile but how do I do it with files in the Pack?


Thanks in advance.

PostPosted: Sep 10, 2007 @ 10:55am
by edge
Hi Jonah,

It's unfortunately not possible to only read a part of a file when using PackGetFileData.

You need to read the whole file and use the pointer to access certain parts of the data. If the file is very big, it may be useful to split it into several smaller parts.

ClassEFile

PostPosted: Sep 10, 2007 @ 11:12am
by jonah
What if I do not pack the file? i.e. use the file direct from the filesystem. In that case can I use ClassEFile's Seek and Read methods to load specific parts of the file. Or does that also load the whole file into memory?


Thanks

PostPosted: Sep 11, 2007 @ 10:08am
by edge
Hi Jonah,

Sure, you're able to seek and read certain parts of the file when it's not packed and on the filesystem directly.

The reason why it needs the whole file in the package files, is because they are compressed (and it needs to decompress the whole file before it can be used).

If you mean seeking in an uncompressed file inside an EDGELIB pack, this feature is not available (yet).