[racket-users] How to identify the target of a symlink?
The link-exists? function will tell me that something is a symlink. How do I tell what it's pointing to? I'm writing code that must move data from one computer to another, and I need a way to say "create the file here and put the data in it" vs "create a symlink here that points to a file over there and put the data in the file" I've been through the Filesystem[1] docs, which offer: link-exists? ; Is it a link? file-or-directory-identity (with as-link? #t) ; get the identity of a file, which can prove that a link isn't the same as the file that it points to, but doesn't help me find the target find-executable-file can track through a chain of links so presumably there is some way to do it. Various other functions (e.g. copy-file) also can distinguish between links and not-links. A general search of the docs yields a lot of hits to html- and collection-related things, but nothing that seems to solve my problem. [1] https://docs.racket-lang.org/reference/Filesystem.html -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] How to identify the target of a symlink?
https://docs.racket-lang.org/reference/Manipulating_Paths.html?q=resolve-path#%28def._%28%28quote._~23~25kernel%29._resolve-path%29%29 On Thu, Sep 28, 2017 at 5:50 PM, David Storrs wrote: > The link-exists? function will tell me that something is a symlink. > How do I tell what it's pointing to? > > I'm writing code that must move data from one computer to another, and > I need a way to say "create the file here and put the data in it" vs > "create a symlink here that points to a file over there and put the > data in the file" > > I've been through the Filesystem[1] docs, which offer: > > link-exists? ; Is it a link? > > file-or-directory-identity (with as-link? #t) ; get the identity of a > file, which can prove that a link isn't the same as the file that it > points to, but doesn't help me find the target > > find-executable-file can track through a chain of links so presumably > there is some way to do it. Various other functions (e.g. copy-file) > also can distinguish between links and not-links. > > > A general search of the docs yields a lot of hits to html- and > collection-related things, but nothing that seems to solve my problem. > > [1] https://docs.racket-lang.org/reference/Filesystem.html > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] How to identify the target of a symlink?
Hopefully the core Racket stuff does what you need. If not, you might take a look at: http://www.neilvandyke.org/racket/canonicalize-path/ -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] How to identify the target of a symlink?
Thanks, Jon. I would not have thought to check Paths. (Obviously.) Thanks, Neil. canonicalize-path looks useful, and my software is mostly going to be used on OSX and/or Linux, so it's a good fit. Dave On Thu, Sep 28, 2017 at 7:32 PM, Jon Zeppieri wrote: > https://docs.racket-lang.org/reference/Manipulating_Paths.html?q=resolve-path#%28def._%28%28quote._~23~25kernel%29._resolve-path%29%29 > > On Thu, Sep 28, 2017 at 5:50 PM, David Storrs wrote: >> The link-exists? function will tell me that something is a symlink. >> How do I tell what it's pointing to? >> >> I'm writing code that must move data from one computer to another, and >> I need a way to say "create the file here and put the data in it" vs >> "create a symlink here that points to a file over there and put the >> data in the file" >> >> I've been through the Filesystem[1] docs, which offer: >> >> link-exists? ; Is it a link? >> >> file-or-directory-identity (with as-link? #t) ; get the identity of a >> file, which can prove that a link isn't the same as the file that it >> points to, but doesn't help me find the target >> >> find-executable-file can track through a chain of links so presumably >> there is some way to do it. Various other functions (e.g. copy-file) >> also can distinguish between links and not-links. >> >> >> A general search of the docs yields a lot of hits to html- and >> collection-related things, but nothing that seems to solve my problem. >> >> [1] https://docs.racket-lang.org/reference/Filesystem.html >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to racket-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.