📜 ⬆️ ⬇️

RAR: creating a store archive

The other day I told you how to get a list of files that contains a rar-archive without using third-party extensions or libraries. In one of the comments flashed the thought that, in principle, despite the closeness of the RAR algorithm, you can manually create an archive without compression. After sitting one evening over the code, I present to your attention a class for creating stored-RAR archives.

I will not describe the format again, it is described quite well here or in my previous article. This time, we will simply consider what the library can do and how we will have ways to expand it in the future.

Work example


  1. $ rar = new store_rar ; # create an instance of the class
  2. $ rar -> create ( "archive.rar" ) ; # create archive
  3. $ rar -> addFile ( "a.txt" ) ; # write a.txt file to it
  4. $ rar -> addDirectory ( "b / c" ) ; # create archive directory "b" with subdirectory "c"
  5. $ rar -> addFile ( "d / e.txt" ) ; # create the "d" directory and write e.txt into it
  6. $ rar -> close ( ) ; # close archive

')
You can get the code with comments on GitHub .

And in fact?


Let's see what this class is capable of:

What is worth keeping in mind:

Why do you need this library:

What I would like to do in the future:

Source: https://habr.com/ru/post/73945/


All Articles