guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get absolute path of given path


From: Matt Wette
Subject: Re: get absolute path of given path
Date: Sun, 6 Sep 2020 08:20:49 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0


On 9/6/20 8:04 AM, Zelphir Kaltstahl wrote:
Hi Guile Users!

In my explorations into making examples for web development, I came
across the question of how to get an absolute path from any given path.
This is useful for example when checking, whether a path points to
something inside a static assets directory, or perhaps sneakily tries to
escape that and access things it should not.

I found in Guile's manual the function (canonicalize-path path).
However, this function has one problem, which makes it not sufficient on
its own: It raises an exception, when a path given points to something
that does not exist. I would like to have a function, that gives me the
absolute path of any path I give as argument, not only for existing
paths. So i went ahead and wrote the following code
(https://notabug.org/ZelphirKaltstahl/guile-examples/src/14a76a6aee18a900ac9b9de2b79ede239f8cf9f0/file-system/path-handling.scm):

Maybe you would like false-if-exception.

https://www.gnu.org/software/guile/manual/html_node/Error-Reporting.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]