I would like to create a "null" rar. I used the command: fsutil file createnew c:\a.rar 1040000. But when I try to add files to this rar I get an error that the rar is damaged.
How can I create a null rar with pre-set size?
|
feedback
|
This question came from our site for professional and enthusiast programmers.
|
What do you mean with null rar?
When you try to add files to the rar, is this with WinRAR or do you do this yourself programmatically? Whichever it is, I think you are using the wrong approach for your problem. I also assume you won't be using compression because that is something you can only let WinRAR do. The first case is only possible when you know the filename beforehand and there is only one file with given size. This is because the rar format contains header blocks that are added before the filename with the file name, CRC info ect. These are things you need to have right if you don't want WinRAR complaining. It is possible to do this with multiple files, beforehand, with null bytes, but you need the actual files to construct it. Then you are just better off doing it right then and there. For the second case as said on Wikipedia:
The following Python code would construct this file. If you open the file in WinRAR, it won't complain. This is the rar Marker block ( MARK_HEAD ) (a magic number) and Archive header ( MAIN_HEAD ). There is no pre-set size: it will grow with each file you add.
I don't understand what you are trying to accomplish, but why don't you just use rar.exe? If you decide to do things yourself, technote.txt is some must read lecture. It is placed in the WinRAR install directory. If you want some example code, here are some projects that use rar in one way or another:
Edit: Check out this rar tutorial for some command line usage examples. | |||||
feedback
|