guix-patches
[Top][All Lists]
Advanced

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

[bug#44130] [PATCH] Add a recursive version of mkdir-p


From: divoplade
Subject: [bug#44130] [PATCH] Add a recursive version of mkdir-p
Date: Fri, 23 Oct 2020 16:14:42 +0200
User-agent: Evolution 3.34.2

Hi,

Le vendredi 23 octobre 2020 à 15:12 +0200, Ludovic Courtès a écrit :
> It’s likely that packages that need ‘mkdir-p’ also need other high-
> level
> file system operations that Gash (say) provides.  In that case, I’d
> encourage people to depend on Gash.  If Gash is too big a dependency
> for
> the project, including its own copy of this 24-line procedure is
> probably acceptable.

This function is needed for nearly all desktop applications. In the
freedesktop.org world of specifications, your application should store
data in different places in the home directory of the user. The
application data, such as your bookmarks, should be stored in
$XDG_DATA_HOME/<app>/, or $HOME/.local/share/<app>/ if XDG_DATA_HOME is
not set. So if that's a fresh system, or you want to have different
folders in your application data, you will need to make sure that an
arbitrary long chain of directories exist before writing your files.
You can't expect a static chain of directories, since you have to rely
on an environment variable. This is one example, but as a general rule,
whenever you want to write to a file, guile will create it if it does
not exist, because the intent is "do whatever it takes to have that
file and let me write to it".

As I explained, copying the function is not a good thing, because it
will need to adapt. If not a package, the solution could take the form
of a gnulib for guile (which makes little sense since the whole guile
is the standard library), or...

> All that said, I do think that Guile itself should eventually include
> some of the utilities found in (guix build utils) or Gash.

I really think that would be the ideal solution. I understand that you
don't want my package (to be fair, I'm not satisfied with one-package-
per-function either), but the need for that particular function exceeds
that of most other from guix build utils or gash.

Look, even guix itself does not care about mkdir! I get 481 instances
of '(mkdir ' in the source, for 1317 instances of '(mkdir-p '. That
should say something about having a mkdir function by default, but not 
mkdir-p. The only functions from guix build utils that have more than
100 calls (detected as '(fun ') are with-directory-excursion (616),
install-file (1018) (half of its job being mkdir-p), copy-recursively
(559), delete-file-recursively (470), find-files (1161), which (1423,
that's more than mkdir-p), modify-phases (4556, that's a lot more but
it's very specific to guix), substitute* (4240, same), wrap-program
(311, same), and invoke (2242). So I think if you want to import one
function from guix build utils into guile, start with mkdir-p!

Best regards,

divoplade






reply via email to

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