diff --git a/file.rkt b/file.rkt index 3d8b5b9..5bfd899 100644 --- a/file.rkt +++ b/file.rkt @@ -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?) diff --git a/scribblings/file.scrbl b/scribblings/file-extensions.scrbl similarity index 78% rename from scribblings/file.scrbl rename to scribblings/file-extensions.scrbl index 0b188b2..c112fea 100644 --- a/scribblings/file.scrbl +++ b/scribblings/file-extensions.scrbl @@ -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))) -] \ No newline at end of file diff --git a/scribblings/list.scrbl b/scribblings/list.scrbl index 5b38ab3..b99ea70 100644 --- a/scribblings/list.scrbl +++ b/scribblings/list.scrbl @@ -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))] diff --git a/scribblings/sugar.scrbl b/scribblings/sugar.scrbl index 742a48c..972a76d 100644 --- a/scribblings/sugar.scrbl +++ b/scribblings/sugar.scrbl @@ -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"] diff --git a/test/main.rkt b/test/main.rkt index fbc4dd7..302e0b9 100644 --- a/test/main.rkt +++ b/test/main.rkt @@ -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"))