I don't know if this question should go here or in another site, so please move it if you think so!
I was thinking 开发者_运维问答that, as a file is basically 1s and 0s, could it be possible to create a file that contains (for example) an image and a mp3? The method I was thinking is just using odd byte positions for one type and even ones for another. Of course this would imply having a special file reader for this.
Am I missing something? Or maybe this is already being done in some places and you could give me an example
Thanks
Of course this is possible. For another example, consider what happens if you compress an image and a sound file using zip, or create a disk image (using e.g. Disk Utility on the Mac)
Many programs use resource formats which can contain multiple types of data. For example the WAD files used by the original Doom game.
You could also think about encapsulating binary files inside an XML file.
However, there is little practical value in doing this yourself using your own encoding - you should use open standards such as the ones above.
It's very hard to ready file bit by bit - it's a lot easier to do it byte by byte. Question is why do you ever need that? It is a lot easier to use special formats for storing multiple files like .tar for example.
From how you describe it it sounds like you want to make an interleaving file loader/ format. A prime example of a well known existing format would be AVI (audio video interleave).
AVI is a spin off of RIFF (resource interchange file format).
精彩评论