Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your lover will never wish to leave you.


comp / comp.lang.tcl / Re: mkzip and a single file

SubjectAuthor
* mkzip and a single filegreg
`* Re: mkzip and a single filegreg
 `* Re: mkzip and a single fileclt.to.davebr
  `* Re: mkzip and a single filegreg
   `- Re: mkzip and a single fileclt.to.davebr

1
Subject: mkzip and a single file
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 2 Jun 2024 04:46 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: mkzip and a single file
Date: Sun, 2 Jun 2024 06:46:44 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <v3gtfk$37cpd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 02 Jun 2024 06:46:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5a9e8aa96bd5f795a69dd0c6f31a1f2e";
logging-data="3388205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MauMEdvQcARWzJSS0Ek5hMQpXNzkYq/k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:tXNmNlDyGvcWu519lzlotHWsR7I=
Content-Language: de-DE
View all headers

Hello,

I'm using mkzip from tcllib to create ZIP archives.
https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/zip/mkzip.md

Problem:

A directory that contains multiple files.
I only want to zip a specific file from that directory,
without including the entire absolute path or other files in the
directory in the ZIP archive.

Target:

only testfile01.txt in the zip file

1.)
set zipfile [file join $sourcedir "testfile01.zip"]
set options [list [file join $sourcedir testfile01.txt]]
:zipfile::mkzip::mkzip $zipfile {*}$options

works, but with absolute path

2.)
set zipfile [file join $sourcedir "testfile01.zip"]
set options [list -directory [file join $sourcedir] -exclude {d* *02.txt}]
::zipfile::mkzip::mkzip $zipfile {*}$options

works without absolute path, but -exclude has to be adjusted
individually each time

Is there a direct way?

best regards
Gregor

Subject: Re: mkzip and a single file
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 2 Jun 2024 08:52 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: mkzip and a single file
Date: Sun, 2 Jun 2024 10:52:22 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <v3hbs6$39kdf$1@dont-email.me>
References: <v3gtfk$37cpd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 02 Jun 2024 10:52:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5a9e8aa96bd5f795a69dd0c6f31a1f2e";
logging-data="3461551"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iKp6nPsVpQxBO+yv6dRnBBAi9N3t42dc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6HOwuzN2Hbnk4156Laz0+TKn55A=
In-Reply-To: <v3gtfk$37cpd$1@dont-email.me>
Content-Language: de-DE
View all headers

Am 02.06.24 um 06:46 schrieb greg:
> Hello,
>
> I'm using mkzip from tcllib to create ZIP archives.
> https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/zip/mkzip.md
>
> Problem:
>
> A directory that contains multiple files.
> I only want to zip a specific file from that directory,
> without including the entire absolute path or other files in the
> directory in the ZIP archive.
>
> Target:
>
> only testfile01.txt in the zip file
>
> 1.)
> set zipfile [file join $sourcedir "testfile01.zip"]
> set options [list  [file join $sourcedir testfile01.txt]]
> :zipfile::mkzip::mkzip $zipfile {*}$options
>
> works, but with absolute path
>
> 2.)
> set zipfile [file join $sourcedir "testfile01.zip"]
> set options [list -directory [file join $sourcedir] -exclude {d* *02.txt}]
> ::zipfile::mkzip::mkzip $zipfile {*}$options
>
> works without absolute path, but -exclude has to be adjusted
> individually each time
>
> Is there a direct way?
>
>
> best regards
> Gregor

Have a solution;

3.)

set zipfile [file join $sourcedir "testfile01.zip"]
set file_to_zip [file join $sourcedir testfile01.txt]
set tempdir [fileutil::tempdir mkzip]
set temp_file [file join $tempdir testfile01.txt]
file copy -force $file_to_zip $temp_file
set options [list -directory [file join $tempdir] testfile01.txt]
::zipfile::mkzip::mkzip $zipfile {*}$options
file delete -force $tempdir

Subject: Re: mkzip and a single file
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 2 Jun 2024 14:29 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Re: mkzip and a single file
Date: Sun, 02 Jun 24 14:29:22 GMT
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <05317173385621001@llp>
References: <v3gtfk$37cpd$1@dont-email.me> <v3hbs6$39kdf$1@dont-email.me>
Injection-Date: Sun, 02 Jun 2024 16:30:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="dd0e35b3910dde7efb0283044485ba86";
logging-data="3569194"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gXtVS3cDi4D8dPXak7Fjy"
Cancel-Lock: sha1:63JoYoSYzZNnCgjkOr1/GN9oLSY=
In-Reply-To: <v3hbs6$39kdf$1@dont-email.me>
View all headers

>From: greg <gregor.ebbing@gmx.de>
>Date: Sun, 2 Jun 2024 10:52:22 +0200
>Subject: Re: mkzip and a single file

This seems to work for me (on Slackware 15ish)

cd $sourcedir
zipfile::mkzip::mkzip testfile01.zip testfile01.txt

Save and restore the current directory using pwd, cd and try if desired.

Dave B

Subject: Re: mkzip and a single file
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 2 Jun 2024 17:23 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: mkzip and a single file
Date: Sun, 2 Jun 2024 19:23:33 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <v3i9ql$3es3c$1@dont-email.me>
References: <v3gtfk$37cpd$1@dont-email.me> <v3hbs6$39kdf$1@dont-email.me>
<05317173385621001@llp>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 02 Jun 2024 19:23:34 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5a9e8aa96bd5f795a69dd0c6f31a1f2e";
logging-data="3633260"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eNYMb9nyYcOCy6W/1duFXdWeE0fOJD2Y="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HWW+QVutUEHiVxn6w0K38ePxDNI=
Content-Language: de-DE
In-Reply-To: <05317173385621001@llp>
View all headers

Am 02.06.24 um 16:29 schrieb clt.to.davebr@dfgh.net:
>> From: greg <gregor.ebbing@gmx.de>
>> Date: Sun, 2 Jun 2024 10:52:22 +0200
>> Subject: Re: mkzip and a single file
>
> This seems to work for me (on Slackware 15ish)
>
> cd $sourcedir
> zipfile::mkzip::mkzip testfile01.zip testfile01.txt
>
> Save and restore the current directory using pwd, cd and try if desired.
>
>
> Dave B
>
Hello Dave,

Thanks for the solution!.
(for me the best solution)

4.
set savedir [pwd]
cd [file join $sourcedir tmpzip]
set options [list testfile01.txt]
::zipfile::mkzip::mkzip $zipfile {*}$options
cd $savedir

A mistake from me in 3
Correct:
set tempdir [::fileutil::maketempdir]

Gregor

Subject: Re: mkzip and a single file
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 3 Jun 2024 15:37 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: Re: mkzip and a single file
Date: Mon, 03 Jun 24 15:37:50 GMT
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <28717174290701001@llp>
References: <v3gtfk$37cpd$1@dont-email.me> <v3hbs6$39kdf$1@dont-email.me> <05317173385621001@llp> <v3i9ql$3es3c$1@dont-email.me>
Injection-Date: Mon, 03 Jun 2024 17:39:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="631969ccec8ba263b48116eb6fead88e";
logging-data="4159120"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hY3Riv/pOMfL9YjG9r0eZ"
Cancel-Lock: sha1:WO6caJXQtGvIRXyXxFgoFM5ZeHg=
In-Reply-To: <v3i9ql$3es3c$1@dont-email.me>
View all headers

Consider wrapping mkzip in a try/finally so errors do not leave you in an unexpected directory:

set savedir [pwd]
cd [file join $sourcedir tmpzip]
try {
set options [list testfile01.txt]
::zipfile::mkzip::mkzip $zipfile {*}$options
} finally {cd $savedir}

Dave B

1

rocksolid light 0.9.8
clearnet tor