fix PR8069
svn: r3056
This commit is contained in:
parent
9b850501a4
commit
2d0cbdba67
|
@ -171,36 +171,29 @@
|
||||||
file))]))
|
file))]))
|
||||||
filename))))
|
filename))))
|
||||||
|
|
||||||
(define file-name-from-path
|
(define (file-name who name)
|
||||||
(lambda (name)
|
(unless (path-string? who)
|
||||||
(unless (path-string? name)
|
(raise-type-error who "path or string" name))
|
||||||
(raise-type-error 'file-name-from-path "path or string" name))
|
(let-values ([(base file dir?) (split-path name)])
|
||||||
(let-values ([(base file dir?) (split-path name)])
|
(and (not dir?) (path? file) file)))
|
||||||
(if (and (not dir?) (path? file))
|
|
||||||
file
|
|
||||||
#f))))
|
|
||||||
|
|
||||||
(define path-only
|
(define (file-name-from-path name)
|
||||||
(lambda (name)
|
(filename 'file-name-from-path))
|
||||||
(unless (path-string? name)
|
|
||||||
(raise-type-error 'path-only "path or string" name))
|
(define (path-only name)
|
||||||
(let-values ([(base file dir?) (split-path name)])
|
(unless (path-string? name)
|
||||||
(cond
|
(raise-type-error 'path-only "path or string" name))
|
||||||
[dir? name]
|
(let-values ([(base file dir?) (split-path name)])
|
||||||
[(path? base) base]
|
(cond [dir? name]
|
||||||
[else #f]))))
|
[(path? base) base]
|
||||||
|
[else #f])))
|
||||||
|
|
||||||
;; name can be any string; we just look for a dot
|
;; name can be any string; we just look for a dot
|
||||||
(define filename-extension
|
(define (filename-extension name)
|
||||||
(lambda (name)
|
(let* ([name (file-name 'filename-extension name)]
|
||||||
(unless (path-string? name)
|
[name (and name (path->bytes name))])
|
||||||
(raise-type-error 'filename-extension "path or string" name))
|
(cond [(and name (regexp-match #rx#"[.]([^.]+)$" name)) => cadr]
|
||||||
(let ([name (if (path? name)
|
[else #f])))
|
||||||
(path->bytes name)
|
|
||||||
name)])
|
|
||||||
(let ([m (regexp-match #rx#"[.]([^.]+)$" name)])
|
|
||||||
(and m
|
|
||||||
(cadr m))))))
|
|
||||||
|
|
||||||
(define (delete-directory/files path)
|
(define (delete-directory/files path)
|
||||||
(unless (path-string? path)
|
(unless (path-string? path)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user