~brown121407/f.scm

63736afc46cad652bee949fe3911d2be6a272fec — Xinglu Chen 1 year, 2 months ago 965e866 master
Add extension.

* f.scm (extension): New procedure.
1 files changed, 9 insertions(+), 0 deletions(-)

M f.scm
M f.scm => f.scm +9 -0
@@ 33,6 33,7 @@
            delete
            traverse
            copy
            extension
            no-extension
            replace-extension)
  #:re-export (chown


@@ 173,6 174,14 @@ appending a #t at the end."))))))
by appending a #t at the end."))))
      (copy-file src dest)))

(define (extension file)
  "Return extension for FILE."
  (let ((ext (string-match ".+\\.(.*)" (basename file))))
    (cond
     ((string-null? file) #f)
     (ext (regexp-substitute #f ext 1))
     (else ""))))

(define (no-extension file)
  "Return FILE path without extension."
  (let ((without-ext (string-match "(.+)\\..*" (basename file))))