Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I would like to write a simple program to join and split files ( for example with extension .001). I know that there are programs available but I'm interested in knowing the algorithms as well as writing an actual program myself.

Thanks for your help
Posted
Comments
tungnk1993 8-Feb-12 10:28am    
So far I have understood the basics, are there any possible optimizations to improve the algorithms/processes ?
Christian Graus 8-Feb-12 11:19am    
IT's a really basic thing. There's no algorithm, just chunks of bytes to be read and written

A file is a stream of bytes. If you want to split or join them, you just write the appropriate data to the file system. If you want to join or split specific file formats, so the files still work, then it might be more complex.
 
Share this answer
 
Well, the algorithm is simple: open for reading the original file, read CHUNK (CHUNK is your magic predefined constant) bytes and write to first output file, e.g. 'out.001'. Repeat such operation until you cannot read more bytes from the original file.
For joining just do the opposite (note: you have an ordered list of file names).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900