6.0.1.13
5 File
(require sugar/file) | package: sugar |
File utilities, mostly in the realm of file extensions. These functions don’t access the filesystem.
Arguments that are pathish? can take either a string or a path. For clarity below, I’ve used strings.
Return the last file extension of file-path as a string, or #f if it has no extension. Omit the intervening . separator.
Examples: | ||||||||||
|
procedure
file-path : pathish? ext : stringish?
Return #t if the last file extension of file-path is ext, otherwise #f.
Examples: | ||||||
|
procedure
(remove-ext file-path) → path?
file-path : pathish?
Remove the last file extension of file-path, and return the path that remains. If file-path has no extension, you just get the same file-path. Does not use the filesystem.
Examples: | ||||||||
|
procedure
(remove-ext* file-path) → path?
file-path : pathish?
Like remove-ext, just more. Remove all file extensions from file-path, and return the path that remains. If file-path has no extensions, you just get the same file-path. Does not use the filesystem.
Examples: | ||||||||
|
procedure
file-path : pathish? ext : stringish?
Return a new file-path with ext appended. Note that this does not replace an existing file extension. If that’s what you want, then do (add-ext (remove-ext file-path) ext).
Examples: | ||||||
|
procedure
(get-enclosing-dir path) → path?
path : pathish?
Return the enclosing directory of path. Does not consult the filesystem about whether path is valid. If you reach the root directory, then (get-enclosing-dir root) will just return root again.
Examples: | |||||||||||
|