Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sequential binary file

Status
Not open for further replies.

Mag0007

MIS
Feb 15, 2005
829
0
0
US
I have a ZeroED binary file,"binfile" (dd if=/dev/zero of=binfile), size is 1024k

Lets say I have 2 random files (file1, 256k; file2, 128k)

How can I put file1 and file2 into this binfile, sequentially, and also have the ability to retreive the files?

TIA
 
> and also have the ability to retreive the files?
Well you're going to have to create an index of some sort.

Say
Code:
struct header {
  char filename[100];
  unsigned long size;
};

Write a header
Write file 1
Write a header
Write file 2

--
 
isn't the header normally set to the beginning of the file when it is opened, and each time a character is read or written, the file position is incremented. In other words, access to the file is normally sequential?
 
Yes.

But you asked how to store two files inside another file, and how to then extract those files again sometime later (much like say tar or zip would do).



--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top