aboutsummaryrefslogtreecommitdiff
path: root/doc/ref/general/util-path.texi
blob: 9c1da19ba35da038907a301445f616e13d543ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@node Path Utilities
@section Path Utilities

An extended path library for Guile. This library builds upon the path
utilities provided by @xref{File System,,,guile}, but adds
manipulation procedures. These procedures should work no matter what
the systems directory delimiter is, even though this documentation
uses ``/'' for its examples.

Provided by the module @code{(hnh util path)}.

@defun path-absolute? string
Alias of @code{absolute-file-name?} from Guile.
@end defun

@defun path-append path paths ...
Joins all strings into a path, squeezing duplicated delimiters, but
ensuring that all delimiters that are needed are there.

Note that delimiters embedded inside the string, which aren't first or
last in a substring (or are the only thing in a string) are
kept. Meaning that
@example
(path-append "/" "hello") ⇒ "/hello"
(path-append "/usr/local/bin" "cmd") ⇒ "/usr/local/bin/cmd"
@end example
@end defun


@defun path-join lst
@lisp
(apply path-append lst)
@end lisp
@end defun


@defun path-split path
Splits path into a list of components.
The first component will be @code{""} if path is absolute.
@end defun


@defun filename-extension filename
Returns the extension of the filename, or the empty string if none exists.
@end defun

@defun realpath path
Equivalent of realpath(3). Absolute file names are returned as is,
while relative filenames gets expanded to absolute filenames.
@end defun

@defun relative-to base path
Returns @var{path} as a relative path relative to @var{base}.

base must be non-empty
@example
(relative-to "/some" "/some/path")
;; ⇒ "path"

(relative-to "/some" "/other/path/")
;; ⇒ "../path"

(relative-to "/a/b/c" "/a/b")
;; ⇒ "/a/b"
@end example

@end defun