-
Notifications
You must be signed in to change notification settings - Fork 0
/
zpfile.zp
31 lines (25 loc) · 874 Bytes
/
zpfile.zp
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
(define file:OS_DELIM #\/) ; TODO: we need a real way to get that
(define (file:extension fname)
"get extension of filename <par>fname</par>.
params:
- fname: the filename
complexity: O(n)
returns: the extenstion as a string"
(let ((flist (string:split fname #\.)))
(list:ref flist (- (length flist) 1))))
(define (file:filename fname)
"get file name of path <par>fname</par>.
params:
- fname: the filename
complexity: O(n)
returns: the file name as a string"
(let ((flist (string:split fname file:OS_DELIM)))
(list:ref flist (- (length flist) 1))))
(define (file:dirname fname)
"get directory name of path <par>fname</par>.
params:
- fname: the filename
complexity: O(n)
returns: the directory name as a string"
(let ((len (length (file:filename fname))))
(substring fname 0 (- (length fname) len))))