###################################################
package require Trf
set in [open file1]
set out [open file2 w]
set in [zip -attach $fp -mode compress ]
fcopy $in $out
#Error: error reading "file4": invalid argument
#Tried doing this way:
zip -in $in -out $out -mode compress
fcopy $in $out
#It returns 0 and doesn't do anything.
#doesn't work with [read $in] either
####################################################
Has anyone tried this before? Am I doing it wrong?
Thanks,
---Victor
#Well, it looks like not too many people use Trf, I decided to go with
an external solution instead.
set in [open "|gzip -c -q -9 myfile"]
set out [open myoutfile w]
fcopy $in $out
#This works very well but, unfortunately, is not portable across
different OSes.
---Victor
> #Well, it looks like not too many people use Trf, I decided to go with
> an external solution instead.
I actually had send a response yesterday, however it seems as if
google groups (the site I posted through) swallowed it.
Let me see if I can reconstruct it.
> On May 7, 9:48 pm, vitic <vit...@gmail.com> wrote:
>> #I am trying to an inline compressing with Trf's zip command and
>> fcopy, like this:
>>
>> ###################################################
>> package require Trf
>>
>> set in [open file1]
>> set out [open file2 w]
>>
>> set in [zip -attach $fp -mode compress ]
First, why are you attaching to $fp, instead of $out ?
From the example 'fp' likely contains a completely unrelated channel.
Second, the result of the 'zip -attach' is the channel you attached
to, so you are additionally overwriting 'in' with something unknown.
I recommend to simply get rid of the assignment.
>> fcopy $in $out
>>
>> #Error: error reading "file4": invalid argument
This is likey what you had in 'fp', an unrelated channel, already closed.
>> #Tried doing this way:
>> zip -in $in -out $out -mode compress
>> fcopy $in $out
>> #It returns 0 and doesn't do anything.
In this mode the zip -in -out has already copied and compressed
everything, leaving nothing for the fcopy to do, hence the 0 zero
result you see. Close in and out, and then look at the file.
>> #doesn't work with [read $in] either
Can't say anything about this, not enough code in the message to make
even a guess about what went wrong in this third attempt.
>> ####################################################
>>
>> Has anyone tried this before? Am I doing it wrong?
>>
>> Thanks,
>>
>> ---Victor
>
>
> set in [open "|gzip -c -q -9 myfile"]
> set out [open myoutfile w]
> fcopy $in $out
>
> #This works very well but, unfortunately, is not portable across
> different OSes.
>
>
> ---Victor
--
So long,
Andreas Kupries <akup...@shaw.ca>
<http://www.purl.org/NET/akupries/>
Developer @ <http://www.activestate.com/>
-------------------------------------------------------------------------------
For the benefit of anyone who might want to implement this, you also
need to set up your file channels, as in:
fconfigure $in -translation binary
fconfigure $out -translation binary
Otherwise the data will be corrupted.
---Victor
Right. I sort of skipped over that in your example. There are some
more things to look out for. The relevant wiki page is
Thanks,
---Victor