* Getting the name of file-like objects
@ 2022-04-01 20:29 Justin Veilleux
2022-04-02 8:32 ` Maxime Devos
2022-04-02 20:03 ` Liliana Marie Prikler
0 siblings, 2 replies; 4+ messages in thread
From: Justin Veilleux @ 2022-04-01 20:29 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
Hi everyone. I'm currently writing a set of helper functions (usually
written using `computed-file` which act on file like objects to
transform them in some way.
For instance, I have a `decompress` function which, given a file-like
object pointing to an archive, will return a computed file object which
it will decompress to it's output.
Everything works very well, but I would like to be able to name the
`computed-file` objects something meaningfull.
```
(define (unzip f)
(computed-file (string-append (name f) "-unzipped")
#~(begin
(system* (string-append #$unzip "/bin/unzip")
"-d" #$output
#$file))
#$out))
```
Is there someting which ressembles the imaginary `name` function I used
above?
Cheers.
[-- Attachment #2: Type: text/html, Size: 988 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the name of file-like objects
2022-04-01 20:29 Getting the name of file-like objects Justin Veilleux
@ 2022-04-02 8:32 ` Maxime Devos
2022-04-05 12:26 ` Ludovic Courtès
2022-04-02 20:03 ` Liliana Marie Prikler
1 sibling, 1 reply; 4+ messages in thread
From: Maxime Devos @ 2022-04-02 8:32 UTC (permalink / raw)
To: Justin Veilleux, guix-devel
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]
Justin Veilleux schreef op vr 01-04-2022 om 16:29 [-0400]:
> (define (unzip f)
> (computed-file (string-append (name f) "-unzipped")
> #~(begin
> (system* (string-append #$unzip "/bin/unzip")
(unrelated) you can do #+(file-append unzip "/bin/unzip") here. The
'file-append' is not very important here, but the #+ is. The
difference between #+ (cf. 'native-inputs) and #$ (cf. 'inputs') is
important when cross-compiling.
Also, I would use 'invoke' instead of 'system*' here -- 'invoke' throws
an exception if it fails (making the derivation fail to build), whereas
'system*' silently returns an integer.
> "-d" #$output
> #$file))
> #$out))
> ```
>
> Is there someting which ressembles the imaginary `name` function
> I used above?
computed-file-name, local-file-name, package-name ... I don't think
there's some generic procedure for this.
Greetings,
Maxime.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the name of file-like objects
2022-04-01 20:29 Getting the name of file-like objects Justin Veilleux
2022-04-02 8:32 ` Maxime Devos
@ 2022-04-02 20:03 ` Liliana Marie Prikler
1 sibling, 0 replies; 4+ messages in thread
From: Liliana Marie Prikler @ 2022-04-02 20:03 UTC (permalink / raw)
To: Justin Veilleux, guix-devel
Hi Justin
Am Freitag, dem 01.04.2022 um 16:29 -0400 schrieb Justin Veilleux:
> Hi everyone. I'm currently writing a set of helper functions
> (usually written using `computed-file` which act on file like
> objects to transform them in some way.
> For instance, I have a `decompress` function which, given a file-like
> object pointing to an archive, will return a computed file object
> which it will decompress to it's output.
> Everything works very well, but I would like to be able to name the
> `computed-file` objects something meaningfull.
> ```
> (define (unzip f)
> (computed-file (string-append (name f) "-unzipped")
> #~(begin
> (system* (string-append #$unzip "/bin/unzip")
> "-d" #$output
> #$file))
> #$out))
> ```
> Is there someting which ressembles the imaginary `name` function I
> used above?
Generally speaking, you'll have to speak to the store to achieve your
goal. For a specific implementation, that fetches a file from a
package (without building the package in question!), see package-file
in (guix packages).
Cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the name of file-like objects
2022-04-02 8:32 ` Maxime Devos
@ 2022-04-05 12:26 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2022-04-05 12:26 UTC (permalink / raw)
To: Maxime Devos; +Cc: guix-devel
Hi,
Maxime Devos <maximedevos@telenet.be> skribis:
> computed-file-name, local-file-name, package-name ... I don't think
> there's some generic procedure for this.
IWBN to address that and have a generic procedure, somehow.
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-05 12:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-01 20:29 Getting the name of file-like objects Justin Veilleux
2022-04-02 8:32 ` Maxime Devos
2022-04-05 12:26 ` Ludovic Courtès
2022-04-02 20:03 ` Liliana Marie Prikler
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).