Merging multiple files


You would have to create/use a file structure. Like, for example, FAT uses tables to indicate the location of files.
If you want an archive that you can extract the content on, you can use a standard zip program and switch off the compression, or use ar.

If you just want to concatenate all the files into a single file:
1. With a Unix shell:
cat file1 file2 ... filen > targetfile

2. With DOS/Windows cmd shell:
copy /b file1+file2+ ... +filen targetfile
@Script Coder:
I don't want to create a file system. Just a file that contains filenames and sizes and files content.

I want to write this program by myself. I don't want to use system commands or another program.
What part of your program do you have trouble with then?
In reading file contents. How to separate file contents?
put a header.
I didn't understand what you said, would you please explain?
You need to design the structure of your archive so you have a header that describes the content the rest of the file.

It's sort of line the Table Of Contents in a book. You open the book, look up the page number of the chapter you're interested in, search for that page and start reading. It's the same with an archive.
The tar program basically concatentates the files while keeping a record of the directory structure - use that maybe?
It's probably a programming assignment, and so can't use an existing solution.
Topic archived. No new replies allowed.