aboutsummaryrefslogtreecommitdiff
path: root/module/hnh
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-05-18 00:15:54 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-05-18 00:15:54 +0200
commitbd3e62661c43d6198fb59d454e4a864726995e62 (patch)
tree358fce681b77077ee3a735894aa2bbb1e38a4851 /module/hnh
parentAdd check rule to makefile. (diff)
downloadcalp-bd3e62661c43d6198fb59d454e4a864726995e62.tar.gz
calp-bd3e62661c43d6198fb59d454e4a864726995e62.tar.xz
Add procedure realpath.
Diffstat (limited to 'module/hnh')
-rw-r--r--module/hnh/util/path.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/module/hnh/util/path.scm b/module/hnh/util/path.scm
index 49b53897..7eac630b 100644
--- a/module/hnh/util/path.scm
+++ b/module/hnh/util/path.scm
@@ -60,3 +60,18 @@
(define-public (filename-extension filename)
(car (reverse (string-split filename #\.))))
+
+
+(define-public (realpath filename)
+ (unless (string? filename)
+ (scm-error 'wrong-type-arg "realpath"
+ "filename not a string: ~a"
+ (list filename) #f))
+ (when (string-null? filename)
+ (scm-error 'wrong-type-arg "realpath"
+ "filename can't be empty"
+ #f #f))
+
+ (if (absolute-file-name? filename)
+ filename
+ (path-append (getcwd) filename)))