mes: Add basename.

* module/mes/posix.mes (basename): New function.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-29 18:33:14 +02:00
parent 4dfe6e00cc
commit b209378fca
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -24,3 +24,10 @@
(define R_OK 0)
(define S_IRWXU #o700)
(define (basename file-name . ext)
(let ((base (last (string-split file-name #\/)))
(ext (and (pair? ext) (car ext))))
(if (and ext
(string-suffix? ext base)) (string-drop-right base (string-length ext))
base)))