123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|566|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> read into a struct

Tue, 28 Apr 2009, 20:32
cthug
How do you read (from memory), into a structure in c (not c++). do you do something like:



as you may have noticed i am reading TAR archives, I want to store the TAR header in a struct which is before each file in the archive and see if it is the correct filename. Well then copy the contents.

Thanks



-=-=-
CTHUG.co.nr
Get Ubuntu
Tue, 28 Apr 2009, 20:58
Cower
Something like this?


For something more advanced, you could look into using mmap to map the file into the process's memory. However, I'm not sure if mmap works under Windows, and there are important differences in how it works between operating systems.
Tue, 28 Apr 2009, 21:04
cthug
That seems the way to do it, btw I am using USTAR (GNU TAR), format. . Oh and this will be cross platform, cuz I am using SDL and openGL, so no OS specific stuff like memory map

Thanks

-=-=-
CTHUG.co.nr
Get Ubuntu
Tue, 28 Apr 2009, 21:24
Cower
Well, that includes the USTAR header, so just check your tar files for the "ustar" magic string and you should be fine.