summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-21 08:48:20 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-21 08:48:20 -0700
commit60782a5351d2306ac69f700bfb5ab458648190d7 (patch)
tree814122f41e65786b3bacf1958d491eb8703de7e8 /txr.1
parent002969ba8021677cb6dc9a29374f174cbb4f8654 (diff)
downloadtxr-60782a5351d2306ac69f700bfb5ab458648190d7.tar.gz
txr-60782a5351d2306ac69f700bfb5ab458648190d7.tar.bz2
txr-60782a5351d2306ac69f700bfb5ab458648190d7.zip
Adding base-name and dir-name functions.
* stream.c (path_sep_chars): New global variable. (detect_path_separators): New static function. (base_name, dir_name): New functions. (stream_init): Call detect_path_separators. Register base-name and dir-name intrinsic functions, and path-sep-chars variable. * stream.h (path_sep_chars, base_name, dir_name): Declared. * txr.c (dirname): Static function removed. (sysroot_init): Use dir_name instead of dirname. * txr.1: Documented dir-name, base-name and path-sep-chars.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.179
1 files changed, 79 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 6a29f53d..ae73c821 100644
--- a/txr.1
+++ b/txr.1
@@ -41445,6 +41445,85 @@ Examples of strings which are not pure relative paths:
$:\eabc
.cble
+.coNP Functions @ dir-name and @ base-name
+.synb
+.mets (dir-name << path )
+.mets (base-name << path )
+.syne
+.desc
+The
+.code dir-name
+and
+.code base-name
+functions calculate, respective, the directory part and
+base name part of a path name.
+
+The calculation is performed in a platform-dependent way, using the
+characters in the variable
+.code path-sep-chars
+as path component separators.
+
+Both functions first remove from any further consideration all superfluous
+trailing occurrences of the directory separator characters from
+.codn path .
+Thus input such as
+.str "a////"
+is reduced to just
+.strn "a" ,
+and
+.str "///"
+is reduced to
+.strn "/" .
+
+The resulting trimmed path is the
+.I "effective path" .
+
+If the effective path is an empty string, then
+.code dir-name
+returns
+.str "."
+and
+.code base-name
+returns the empty string.
+
+If the effective path is not empty, and contains no path separator
+characters, then
+.code dir-name
+returns
+.str "."
+and
+.code base-name
+returns the effective path.
+
+Otherwise, the effective path is divided into two parts: the
+.I "raw directory prefix"
+and the remainder.
+
+The raw directory path is the maximally long prefix of the effective
+path which ends in a separator character.
+
+The
+.code dir-name
+function returns the raw directory prefix, if that prefix consists of
+nothing but a single directory separator character. Otherwise it
+returns the raw directory prefix, with the trailing path separator
+removed.
+
+The
+.code base-name
+function returns the remaining part of the effective path, after
+the raw directory prefix.
+
+.coNP Variable @ path-sep-chars
+.desc
+The
+.code path-sep-chars
+variable holds a string consisting of the characters which the underlying
+operating system recognizes as path name separators.
+
+Altering the value of this variable has no effect on any \*(TL library
+function.
+
.coNP Functions @ read and @ iread
.synb
.mets (read >> [ source >> [ error-stream >> [ error-retval <> [ name ]]]])