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

reading files into blocks

 [1/7] from: sharriff:aina:med-iq at: 7-Nov-2000 17:44


Hello! can someone tell me how to read files as files into blocks?: [ file.txt file.zip file.gif file.jpg ] using: fileblock: read/binary %file.zip stores binary data which I cannot parse. Ideas? Sharriff Aina med.iq information & quality in healthcare AG

 [2/7] from: petr::krenzelok::trz::cz at: 7-Nov-2000 19:14


----- Original Message ----- From: <[Sharriff--Aina--med-iq--de]> To: <[rebol-list--rebol--com]> Sent: Tuesday, November 07, 2000 6:44 PM Subject: [REBOL] reading files into blocks
> Hello! > > can someone tell me how to read files as files into blocks?: > > [ file.txt file.zip file.gif file.jpg ]
?? if you will read %somedir/ it will give you block of files, or not? e.g.:
>> block: read %.
== [%public/ %rebl.exe %user.r %rebol.r %rebol.exe %browse-system.r %games/ %new-view031.zip %udalosti.zip %asko/ %obr.jpg %ppm.r %...
>> print read block/3 ; will print content of user.r file ... > > using: > fileblock: read/binary %file.zip > > stores binary data which I cannot parse.
I don't understand what you want to achieve, sorry. You can't load .zip archive into block of files, although it would be great to be able to do so ... the same way as rebol loads gifanims into block of gifs .... -pekr-

 [3/7] from: al:bri:xtra at: 8-Nov-2000 16:02


Sharriff wrote:
> can someone tell me how to read files as files into blocks?: > > [ file.txt file.zip file.gif file.jpg ] > > using: > fileblock: read/binary %file.zip > > stores binary data which I cannot parse. > > Ideas?
map [ file.txt file.zip file.gif file.jpg ] func [file] [read/binary file] The result will be a block with four big chunks of binary data. I hope that helps! Andrew Martin Map is available on my site: http://members.nbci.com/AndrewMartin/Rebol/ ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [4/7] from: sharriff:aina:med-iq at: 8-Nov-2000 7:08


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? Regards Sharriff Aina med.iq information & quality in healthcare AG "Petr Krenzelok" An: <[rebol-list--rebol--com]> <petr.krenzel Kopie: [ok--trz--cz]> Thema: [REBOL] Re: reading files into blocks Gesendet von: rebol-bounce@ rebol.com 07.11.00 18:14 Bitte antworten an rebol-list ----- Original Message ----- From: <[Sharriff--Aina--med-iq--de]> To: <[rebol-list--rebol--com]> Sent: Tuesday, November 07, 2000 6:44 PM Subject: [REBOL] reading files into blocks
> Hello! > > can someone tell me how to read files as files into blocks?: > > [ file.txt file.zip file.gif file.jpg ]
?? if you will read %somedir/ it will give you block of files, or not? e.g.:
>> block: read %.
== [%public/ %rebl.exe %user.r %rebol.r %rebol.exe %browse-system.r %games/ %new-view031.zip %udalosti.zip %asko/ %obr.jpg %ppm.r %...
>> print read block/3 ; will print content of user.r file ... > > using: > fileblock: read/binary %file.zip > > stores binary data which I cannot parse.
I don't understand what you want to achieve, sorry. You can't load .zip archive into block of files, although it would be great to be able to do so ... the same way as rebol loads gifanims into block of gifs .... -pekr-

 [5/7] from: sharriff:aina:med-iq at: 8-Nov-2000 7:31


YESSIR IT DOES HELP!! Thanks Sharriff Aina med.iq information & quality in healthcare AG "Andrew Martin" An: <[rebol-list--rebol--com]> <[Al--Bri--xtra]. Kopie: co.nz> Thema: [REBOL] Re: reading files into blocks Gesendet von: rebol-bounce@ rebol.com 08.11.00 16:02 Bitte antworten an rebol-list Sharriff wrote:
> can someone tell me how to read files as files into blocks?: > > [ file.txt file.zip file.gif file.jpg ] > > using: > fileblock: read/binary %file.zip > > stores binary data which I cannot parse. > > Ideas?
map [ file.txt file.zip file.gif file.jpg ] func [file] [read/binary file] The result will be a block with four big chunks of binary data. I hope that helps! Andrew Martin Map is available on my site: http://members.nbci.com/AndrewMartin/Rebol/ ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [6/7] 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
<<quoted lines omitted: 7>>
> 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-

 [7/7] from: sharriff:aina:med-iq at: 8-Nov-2000 8:29


Thanks Petr! exactly what I wanted, now I´ve learnt something this morning! I tried out Carls code; it works like a dream but I can´t get its workings in my newbie-rebol-head petr said-> "I am not REBOL guru, you should ask better advanced rebollers here :-)" you´re being too modest, your reply came back as soon as I hit the submit button when posting the question :-) Much thanks Sharriff Aina med.iq information & quality in healthcare AG

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted