Skip to content

Commit

Permalink
extension
Browse files Browse the repository at this point in the history
  • Loading branch information
awwx committed Jun 16, 2011
1 parent 9c74ab6 commit b81703e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion path.arc
@@ -1,4 +1,4 @@
(use arc cwd values)
(use arc cwd values re)

(ail-code (racket-require (racket-prefix-in racket- scheme/path)))

Expand All @@ -13,6 +13,10 @@
(aif (ar-fnil (racket-file-name-from-path path))
(racket-path->string it)))

(def extension (path)
(aand (filepart path)
(cadr (re-match "\\.([^\\.]+)$" it))))

(def fullpath (path (o basedir cwd))
(racket-path->string
(racket-simplify-path
Expand Down
21 changes: 21 additions & 0 deletions path.t
Expand Up @@ -31,6 +31,27 @@ nil
> (filepart "foo")
"foo"
> (extension "foo")
nil
> (extension "foo.")
nil
> (extension "foo.a")
"a"
> (extension "foo.a.")
nil
> (extension "foo.arc")
"arc"
> (extension "/a/b/c/foo.bar/")
nil
> (extension "/a/b/c/foo.bar")
"bar"
> (fullpath "/a/b/c/foo.bar")
"/a/b/c/foo.bar"
Expand Down

0 comments on commit b81703e

Please sign in to comment.