remove get-enclosing-dir

dev-0.1
Matthew Butterick 8 years ago
parent aa0d885a6f
commit a10be7071c

@ -2,11 +2,6 @@
(require "define.rkt" racket/set "coerce.rkt" racket/path "unstable/string.rkt")
(define+provide+safe (get-enclosing-dir p)
(coerce/path? . -> . path?)
(simplify-path (build-path (->path p) 'up)))
;; does path have a certain extension
(define+provide+safe (has-ext? x ext)
(coerce/path? coerce/string? . -> . coerce/boolean?)

@ -5,10 +5,10 @@
@(define my-eval (make-base-eval))
@(my-eval `(require sugar))
@title{File}
@title{File extensions}
@defmodule[#:multi (sugar/file (submod sugar/file safe))]
File utilities, mostly in the realm of file extensions. These functions don't access the filesystem.
These functions don't access the filesystem.
Arguments that are @racket[pathish?] can take either a string or a path. For clarity below, I've used strings.
@ -72,18 +72,3 @@ Return a new @racket[_file-path] with @racket[_ext] appended. Note that this doe
(add-ext "foo" "txt")
(add-ext "foo.txt" "jpg")
(add-ext (remove-ext "foo.txt") "jpg")]
@defproc[
(get-enclosing-dir
[path pathish?])
path?]
Return the enclosing directory of @racket[_path]. Does not consult the filesystem about whether @racket[_path] is valid. If you reach the @racket[_root] directory, then @racket[(get-enclosing-dir _root)] will just return @racket[_root] again.
@examples[#:eval my-eval
(define bin (string->path "/usr/bin"))
bin
(get-enclosing-dir bin)
(get-enclosing-dir (get-enclosing-dir bin))
(get-enclosing-dir (get-enclosing-dir (get-enclosing-dir bin)))
]

@ -5,7 +5,7 @@
@(define my-eval (make-base-eval))
@(my-eval `(require sugar racket/list))
@title{List}
@title{Lists}
@defmodule[#:multi (sugar/list (submod sugar/list safe))]

@ -27,7 +27,7 @@ Sugar can be invoked two ways: as an ordinary library, or as a library with cont
@include-section["debug.scrbl"]
@include-section["file.scrbl"]
@include-section["file-extensions.scrbl"]
@include-section["list.scrbl"]

@ -94,9 +94,6 @@
(check-not-equal? (remove-ext* foo.bar.txt-path) foo.bar-path) ; removes more than one ext
(check-equal? (remove-ext* foo.bar.txt-path) foo-path)
(check-equal? (get-enclosing-dir "/Users/MB/foo.txt") (->path "/Users/MB/"))
(check-equal? (get-enclosing-dir "/Users/MB/foo/") (->path "/Users/MB/"))
(check-true (has-binary-ext? "foo.MP3"))
(check-false (has-binary-ext? "foo.py"))

Loading…
Cancel
Save