Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Antwort: Re: reading files into blocks

From: petr:krenzelok:trz:cz at: 8-Nov-2000 9:14

[Sharriff--Aina--med-iq--de] wrote:
> Hi Petr! > > I would like the ability to compress a file or files that I have selected > from the created block for compression and relocation, actually I´m trying > to code a backup utility . I´ve tried reading Carls "RIP" archiver code, > but there are some certain parts which are not clear to me. I think trying > to code something of the sort myself would help me in learnng REBOL . I > have thought of making words out of the names of the files in a given > directory and inserting them in a block for manipulation, but I have the > feeling that there must be a cleaner and economical way. Should I convert > them all to the type BINARY! and the insert them into words which are then > inserted into my File block?
1) I am not REBOL guru, you should ask better advanced rebollers here :-) 2) Well, let's try it anyway: at your first step you can try yourself just reading the file and writing it back to your disk ->> size? %view.zip == 258990 ->> length? tmp: read %view.zip == 258988 As you can see now, the length of the tmp is not the same as the size of the file ... we can check by writing file back to disk and trying to access it .. ->> write %viewx.zip tmp result: I can't access the archive from my Windows Commander .... we have to use read/binary ... ->> ble: read/binary %loga.bmp == #{ 424DE6C004000000000036000000280000005001000035010000010018000000 0000B0C00400CE0E0000C40E00000000000000000000FFFFFFFFFFFFFFFF... ->> size? %loga.bmp == 311526 ->> length? ble == 311526 Size and the length of the string are both the same ...
>> length? compress copy ble
== 19542 So the compressed bitmap is much smaller ...
>> write/binary %loga.pack compress copy ble >> write/binary %loga2.bmp decompress read/binary %loga.pack
After unpacking and writing back to .bmp format we can access the file with no further problems ... Carl's RIP code is OK, - it's logical to save the code neede for unpacking with the archive, as everything you have to do is to 'do the .rip file. If such code wouldn't be inside, you couldn't distribute it, as it would require other users to know, how to properly unpack it .... 3) as for your aproach, you could create block of compressed files, and save it to disk ... ->> files: copy [] == [] ->> insert tail files %loga.bmp == [] ->> insert tail files compress read/binary %loga.bmp == [] ->> insert tail files %loga2.bmp == [] ->> insert tail files compress read/binary %loga2.bmp == [] ->> save %files.sav files ->> ble: load %files.sav == [%loga.bmp #{ 789CED7D3D76EB3AB3E57D6B75FCEE093B93C3CEECA43B9557E7BDAC19483390 6620CDC09E813403710664F0E2266720459D4A3370EFAA224... It works, now using simple loop you can unpack and write the files to the disk: ->> foreach [filename archive] ble [write/binary filename decompress archive] Hope it helps a little bit ... Cheers, -pekr-