Wrappers for java.nio.file Path and Files utilities.
Wrappers for java.nio.file Path and Files utilities.
(absolute-path a-path)
Convert to Path, get absolute path via Path.toAbsolutePath method.
Convert to Path, get absolute path via Path.toAbsolutePath method.
(absolute? a-path)
Checks if resulting Path is absolute via Path.isAbsolute call.
Checks if resulting Path is absolute via Path.isAbsolute call.
(all-subpaths a-path)
Returns all Path ancestors from given point, going up.
Lazy!
Returns all Path ancestors from given point, going up. Lazy!
(attr a-path attribute)
(attr a-path attribute options)
Get attribute from a Path via Files/getAttribute call.
Accepts link options.
Get attribute from a Path via Files/getAttribute call. Accepts link options.
(attr! a-path attribute value)
(attr! a-path attribute value options)
Set attribute value on a Path via Files/setAttribute call.
Accepts link options.
Set attribute value on a Path via Files/setAttribute call. Accepts link options.
(attrs a-path attributes)
(attrs a-path attributes options)
Produces a map of selected attributes via Files/readAttributes call.
Accepts link options.
Attributes can be:
"" for all basic attributes, "dos:" for all DOS expected attributes, "posix:*" for all POSIX attributes, "size,lastModifiedTime,lastAccessTime" to get selected basic values "posix:permissions,size" to pick more specifig values.
Produces a map of selected attributes via Files/readAttributes call. Accepts link options. Attributes can be: "*" for all basic attributes, "dos:*" for all DOS expected attributes, "posix:*" for all POSIX attributes, "size,lastModifiedTime,lastAccessTime" to get selected basic values "posix:permissions,size" to pick more specifig values.
(attrs-struct path)
(attrs-struct path options)
(attrs-struct path attr-class options)
Read Path attributes into given class instance via Files/readAttributes call.
Accepts attribute class and link options. Defaults to BasicFileAttributes class and no options.
Read Path attributes into given class instance via Files/readAttributes call. Accepts attribute class and link options. Defaults to BasicFileAttributes class and no options.
(basename a-path)
Convert to path, make absolute, normalize, get file-name, stringify that.
Convert to path, make absolute, normalize, get file-name, stringify that.
(buffered-reader a-path)
(buffered-reader a-path charset)
Produces BufferedReader with Files/newBufferedReader call.
Produces BufferedReader with Files/newBufferedReader call.
(buffered-writer a-path options)
(buffered-writer a-path charset options)
Produces BufferedWriter with Files/newBufferedWriter call.
Produces BufferedWriter with Files/newBufferedWriter call.
(bytes->path a-path some-bytes options)
Writes some-bytes to a-path via Files/write call.
Accepts open options.
Writes some-bytes to a-path via Files/write call. Accepts open options.
(charset-please enc)
Get Charset or String, give Charset back via Charset/forName call.
Get Charset or String, give Charset back via Charset/forName call.
Best effort Conversion protocol.
Best effort Conversion protocol.
(->file this)
Convert to File instance.
Convert to File instance.
(->path this)
Convert to Path instance.
Convert to Path instance.
(->string this)
Convert to String instance.
Convert to String instance.
(->uri this)
Convert to URI instance.
Convert to URI instance.
(->url this)
Convert to URL instance.
Convert to URL instance.
(copy! file-1 file-2)
(copy! file-1 file-2 options)
Copy file-1 to file-2 via Files/copy call.
Accepts copy options
See stream-in!
and stream-out!
for copies from and to streams.
Copy file-1 to file-2 via Files/copy call. Accepts copy options See `stream-in!` and `stream-out!` for copies from and to streams.
Map of keywords to StandardCopyOption enums.
Map of keywords to StandardCopyOption enums.
(copy-opts)
(copy-opts options)
Accepts opts, keywords are subbed with copy-option, other values passed on.
Accepts opts, keywords are subbed with copy-option, other values passed on.
(copy-tree! from to)
(copy-tree! from to options)
Recursively copy a file tree with copy options in iteration order.
Returns a lazy sequence of [from to] path pairs. Skips entry point directory unless it's explicitly part of to path. If from is a file copies that file under to directory. If skipped then default copy options are :copy-attributes and :replace-existing. If :copy-attributes specified then tries to at least maintain last-modified-time across files and directories.
It is lazy, so either dorun or realize into a collection.
Recursively copy a file tree with copy options in iteration order. Returns a lazy sequence of [from to] path pairs. Skips entry point directory unless it's explicitly part of to path. If from is a file copies that file under to directory. If skipped then default copy options are :copy-attributes and :replace-existing. If :copy-attributes specified then tries to at least maintain last-modified-time across files and directories. It is lazy, so either dorun or realize into a collection.
(create-directories! a-path)
(create-directories! a-path attrs)
Create all directories in Path via Files/createDirectories call.
Accepts optional FileAttribute container.
Create all directories in Path via Files/createDirectories call. Accepts optional FileAttribute container.
(create-directory! a-path)
(create-directory! a-path attrs)
Create directory in Path via Files/createDirectory call.
Accepts optional FileAttribute container.
Create directory in Path via Files/createDirectory call. Accepts optional FileAttribute container.
(create-file! a-path)
(create-file! a-path attrs)
Create file in Path via Files/createFile call.
Create file in Path via Files/createFile call.
(create-link! link-path existing-path)
Create hard link to existing-path in link-path via Files/createLink call.
Create hard link to existing-path in link-path via Files/createLink call.
(create-symbolic-link! link-path existing-path)
(create-symbolic-link! link-path existing-path attrs)
Create link-path to existing-path symbolic link via Files/createSymbolicLink call.
Create link-path to existing-path symbolic link via Files/createSymbolicLink call.
(create-temp-directory! prefix)
(create-temp-directory! prefix attrs)
Create temporary directory at default TEMP location with given prefix via Files/createTempDirectory call.
Create temporary directory at default TEMP location with given prefix via Files/createTempDirectory call.
(create-temp-directory-at! a-path prefix)
(create-temp-directory-at! a-path prefix attrs)
Create a temporary directory at Path location with given prefix via Files/createTempDirectory call.
Create a temporary directory at Path location with given prefix via Files/createTempDirectory call.
(create-temp-file! prefix suffix)
(create-temp-file! prefix suffix attrs)
Create temporary file at default TEMP location with given prefix and suffix via Files/createTempFile call.
Create temporary file at default TEMP location with given prefix and suffix via Files/createTempFile call.
(create-temp-file-at! a-path prefix suffix)
(create-temp-file-at! a-path prefix suffix attrs)
Create temporary file at Path location with given prefix and suffix via Files/createTempFile call.
Create temporary file at Path location with given prefix and suffix via Files/createTempFile call.
(cwd)
Current working directory of JVM instance as absolute path.
Current working directory of JVM instance as absolute path.
(delete! a-path)
Delete a file via Files/delete call.
Delete a file via Files/delete call.
(delete-if-exists! a-path)
Delete a fil via Files/deleteIfExists call.
Delete a fil via Files/deleteIfExists call.
(delete-on-exit! a-file)
Mark given file for deletion on JVM exit via File.deleteOnExit call.
Mark given file for deletion on JVM exit via File.deleteOnExit call.
(delete-tree! a-path)
(delete-tree! a-path skip-root?)
Recursively delete all files, then directories. Returns sequence of paths.
Walks the tree depth-first, files get deleted in FIFO order and directories go in LIFO order. Lazy, so please make sure to either use dorun or realize it into a collection.
Recursively delete all files, then directories. Returns sequence of paths. Walks the tree depth-first, files get deleted in FIFO order and directories go in LIFO order. Lazy, so please make sure to either use dorun or realize it into a collection.
(dir->stream a-path)
Returns a Stream<Path> of directory contents.
Remember to close the Stream after use.
Returns a Stream<Path> of directory contents. Remember to close the Stream after use.
(dir->vec a-path)
Returns a [Path] of directory contents.
Returns a [Path] of directory contents.
(directory? a-path)
(directory? a-path options)
Checks if given file is a directory via Files/isDirectory call.
Accepts link options.
Checks if given file is a directory via Files/isDirectory call. Accepts link options.
(ends-with? path-1 path-2)
Check if Path path-1 ends with path-2 via Path.endsWith call.
Check if Path path-1 ends with path-2 via Path.endsWith call.
(executable? a-path)
Checks if resulting Path is executable via Files/isExecutable call.
Checks if resulting Path is executable via Files/isExecutable call.
(exists? a-path)
(exists? a-path options)
Checks if resulting Path exists via Files/exists call.
Accepts link options.
Checks if resulting Path exists via Files/exists call. Accepts link options.
(file-attrs)
(file-attrs attributes)
Accepts attributes, packs them into FileAttribute typed array.
Accepts attributes, packs them into FileAttribute typed array.
(file-name a-path)
Convert to Path, get file name Path via Path.getFileName method.
Convert to Path, get file name Path via Path.getFileName method.
(file-store a-path)
Get file store of Path via Files/getFileStore call.
Get file store of Path via Files/getFileStore call.
(file-system a-path)
Convert to Path, get file system via Path.getFileSystem call.
Convert to Path, get file system via Path.getFileSystem call.
(file? a-path)
(file? a-path options)
Checks if resulting Path is a regular file via Path.isRegularFile call.
Accepts link options.
Checks if resulting Path is a regular file via Path.isRegularFile call. Accepts link options.
(fs-roots)
Get available filesystem roots as paths from File/listRoots call.
Get available filesystem roots as paths from File/listRoots call.
(hidden? a-path)
Checks if resulting Path is a hidden file via Files/isHidden call.
Checks if resulting Path is a hidden file via Files/isHidden call.
(input-stream a-path)
(input-stream a-path options)
Produces InputStream with Files/newInputStream call.
Produces InputStream with Files/newInputStream call.
(is-empty? a-path)
True for childless directories, 0 byte files and non-existing Paths.
Checks for existence first, then tries to resolve with real-path.
Anything else: throws ExceptionInfo.
True for childless directories, 0 byte files and non-existing Paths. Checks for existence first, then tries to resolve with real-path. Anything else: throws ExceptionInfo.
(last-modified-time a-path)
(last-modified-time a-path options)
Get last modified time FileTime via Files/getLastModifiedTime call.
Accepts link options.
Get last modified time FileTime via Files/getLastModifiedTime call. Accepts link options.
(last-modified-time! a-path lmt)
Set last modified time value from FileTime via Files/setLastModifiedtime call.
Set last modified time value from FileTime via Files/setLastModifiedtime call.
(lines->path a-path some-lines options)
(lines->path a-path some-lines charset options)
Writes some-lines Iterable to a-path via Files/write call.
Accepts open options.
Writes some-lines Iterable to a-path via Files/write call. Accepts open options.
Map of keywords to LinkOption enums.
Map of keywords to LinkOption enums.
(link-opts)
(link-opts options)
Accepts opts, keywords are subbed with link-option, other values passed on.
Accepts opts, keywords are subbed with link-option, other values passed on.
(lookup-option option-object)
Reverse lookup of option object to respective keyword. Not found: nil.
Reverse lookup of option object to respective keyword. Not found: nil.
(move! path-1 path-2)
(move! path-1 path-2 options)
Move path-1 to path-2 via Files/move call.
Accepts copy options.
Move path-1 to path-2 via Files/move call. Accepts copy options.
(mtime a-path)
Get last modified time as Instant from a path.
Get last modified time as Instant from a path.
(mtime! a-path)
(mtime! a-path an-instant)
Change modified time of file based on given Instant or to current time.
Change modified time of file based on given Instant or to current time.
(normalize-path a-path)
Convert to Path, normalize it via Path.normalize call
Convert to Path, normalize it via Path.normalize call
(not-exists? a-path)
(not-exists? a-path options)
Checks if resulting Path does not exist via Files/notExists call.
Accepts link options.
Checks if resulting Path does not exist via Files/notExists call. Accepts link options.
Map of keywords to StandardOpenOption enums.
Map of keywords to StandardOpenOption enums.
(open-opts)
(open-opts options)
Accepts opts, keywords are subbed with open-option, other values passed on.
Accepts opts, keywords are subbed with open-option, other values passed on.
(output-stream a-path)
(output-stream a-path options)
Produces OutputStream with Files/newOutputStream call.
Produces OutputStream with Files/newOutputStream call.
(owner a-path)
(owner a-path options)
Get UserPrincipal via Files/getOwner call.
Accepts link options.
Get UserPrincipal via Files/getOwner call. Accepts link options.
(owner! a-path new-owner)
Set UserPrincipal owner on a Path via Files/setOwner call.
Set UserPrincipal owner on a Path via Files/setOwner call.
(parent-path a-path)
Convert to Path, get parent Path via Path.getParent method.
Convert to Path, get parent Path via Path.getParent method.
(path path & paths)
Builds a Path from given String(s) via Path/get static method.
Runs all arguments through to-string to avoid trouble, so just keep in mind that Conversions protocol and the fact that nil returns valid, empty string, which does not produce a path segment, but when resolved to absolute path will be equal to current working directory.
This allows to work with strings, paths, files and nils with no hassle and with URLs and URIs with some attention, as their string representations are absolute paths.
Builds a Path from given String(s) via Path/get static method. Runs all arguments through to-string to avoid trouble, so just keep in mind that Conversions protocol and the fact that nil returns valid, empty string, which does not produce a path segment, but when resolved to absolute path will be equal to current working directory. This allows to work with strings, paths, files and nils with no hassle and with URLs and URIs with some attention, as their string representations are absolute paths.
(path->bytes a-path)
Returns bytes content via Files/readAllBytes call.
Returns bytes content via Files/readAllBytes call.
(path->lines a-path)
(path->lines a-path charset)
Returns a lazy Stream<String> from Path and encoding via Files/lines call.
Remember to close Stream after use.
Returns a lazy Stream<String> from Path and encoding via Files/lines call. Remember to close Stream after use.
(path->string a-path)
(path->string a-path charset)
Returns string content via Files/readString call.
Returns string content via Files/readString call.
(path-elements a-path)
Convert to Path, return vector of Path.iterator produced segments.
Convert to Path, return vector of Path.iterator produced segments.
(path-name-at a-path idx)
Convert to Path, get segment Path at index idx via Path.getName call.
Convert to Path, get segment Path at index idx via Path.getName call.
(path-name-count a-path)
Convert to Path, get segment count via Path.getNameCount call.
Convert to Path, get segment count via Path.getNameCount call.
(pathable? obj)
Checks if obj has ->string defined.
Checks if obj has ->string defined.
(perms->attr permissions)
Produce a set of FileAttributes based on PosixFilePermission, via call to PosixFilePermissions/asFileAttribute.
Produce a set of FileAttributes based on PosixFilePermission, via call to PosixFilePermissions/asFileAttribute.
(perms->string permissions)
Translate collection of PosixFilePermission objects into a String via call to PosixFilePermissions/toString.
Counterpart of string->perms function.
Translate collection of PosixFilePermission objects into a String via call to PosixFilePermissions/toString. Counterpart of string->perms function.
(posix-perms a-path)
(posix-perms a-path options)
Get POSIX file permissions via Files/getPosixFilePermissions call.
Accepts link options.
Get POSIX file permissions via Files/getPosixFilePermissions call. Accepts link options.
(posix-perms! a-path file-permissions)
Sets POSIX file permissions on Path via Files/setPosixFilePermissions call.
Sets POSIX file permissions on Path via Files/setPosixFilePermissions call.
(probe-content-type a-path)
Try to probe content type via Files/probeContentType call.
Try to probe content type via Files/probeContentType call.
(pruning-path-seq entry)
(pruning-path-seq entry follow?)
Like file-seq, but works on Path and can prune branches based on predicate.
If follow?
returns false - Path is not processed, directory not entered.
Predicate will be first executed on given entry.
Why?
Ever went into a massive .svn directory? Now you can have tree-seq that prunes the entire Path of enquiry and moves on. Pretty nice!
Like file-seq, but works on Path and can prune branches based on predicate. If `follow?` returns false - Path is not processed, directory not entered. Predicate will be first executed on given entry. Why? Ever went into a massive .svn directory? Now you can have tree-seq that prunes the entire Path of enquiry and moves on. Pretty nice!
(readable? a-path)
Checks if resulting Path is readable via Files/isReadable call.
Checks if resulting Path is readable via Files/isReadable call.
(real-path a-path)
(real-path a-path options)
Convert to Path, get real path via Path.toRealPath method.
Accepts link options.
Convert to Path, get real path via Path.toRealPath method. Accepts link options.
(relativize-path path-1 path-2)
Create relative Path between path-1 and path-2 via Path.relativize call.
Create relative Path between path-1 and path-2 via Path.relativize call.
(resolve-path path-1 path-2)
Create resolved Path between path-2 and path-1 via Path.resolve call.
Create resolved Path between path-2 and path-1 via Path.resolve call.
(resolve-sibling-path path-1 path-2)
Create sibling Path between path-1 and path-2 via Path.resolveSibling call.
Create sibling Path between path-1 and path-2 via Path.resolveSibling call.
(root-path a-path)
Convert to Path, get root Path via Path.getRoot, nil if none present.
Convert to Path, get root Path via Path.getRoot, nil if none present.
(same-file? file-1 file-2)
Checks if file-1 and file-2 the same file via Files/isSameFile call.
Checks if file-1 and file-2 the same file via Files/isSameFile call.
(sane-path a-path)
Make path absolute first and normalized later. Keep your sanity.
Make path absolute first and normalized later. Keep your sanity.
(select-options pool opts)
Lookup keyword options in given pool, translate if found, drop otherwise. Pass non-keywords 'as is'.
Lookup keyword options in given pool, translate if found, drop otherwise. Pass non-keywords 'as is'.
(size a-path)
Read size attribute of a Path via Files/size call.
Read size attribute of a Path via Files/size call.
(starts-with? path-1 path-2)
Check if Path path-1 starts with path-2 via Path.startsWith call.
Check if Path path-1 starts with path-2 via Path.startsWith call.
(stream-in! stream-1 path-2)
(stream-in! stream-1 path-2 options)
Copy InputStream stream-1 to path-2 via Files/copy call.
Accepts copy options
See copy!
for file to file and stream-out!
for to stream copy.
Copy InputStream stream-1 to path-2 via Files/copy call. Accepts copy options See `copy!` for file to file and `stream-out!` for to stream copy.
(stream-out! path-1 stream-2)
Copy path-1 to OutputStream via Files/copy call.
See stream-in!
for stream to file and copy!
for file to file.
Copy path-1 to OutputStream via Files/copy call. See `stream-in!` for stream to file and `copy!` for file to file.
(string->path a-path a-string options)
(string->path a-path a-string charset options)
Writes a-string to a-path via Files/writeString call.
Accepts open options.
Writes a-string to a-path via Files/writeString call. Accepts open options.
(string->perms rwx)
Translate 'rwxrwxrwx' String into PosixFilePermission enums set via call to PosixFilePermissions/fromString.
Counterpart of perms->string function.
Translate 'rwxrwxrwx' String into PosixFilePermission enums set via call to PosixFilePermissions/fromString. Counterpart of perms->string function.
(subpath a-path begin end)
Call Path.subpath to produce segments spanning from begin to end indices.
Call Path.subpath to produce segments spanning from begin to end indices.
(symbolic-link? a-path)
Checks if resulting Path is a symbolic link via Files/isSymbolicLink call.
Checks if resulting Path is a symbolic link via Files/isSymbolicLink call.
(to-file object)
Tries to convert object to File.
Tries to convert object to File.
(to-path object)
Tries to convert object to Path.
Tries to convert object to Path.
(to-string object)
Tries to convert object to String.
Tries to convert object to String.
(to-uri object)
Tries to convert object to URI.
Tries to convert object to URI.
(to-url object)
Tries to convert object to URL.
Tries to convert object to URL.
(url-decode a-string)
(url-decode a-string enc)
Calls URLDecoder.decode on a-string with encoding, UTF-8 by default.
Calls URLDecoder.decode on a-string with encoding, UTF-8 by default.
(url-decode-path a-path)
URL-decode given path as UTF-8, element by element.
URL-decode given path as UTF-8, element by element.
(url-encode a-string)
(url-encode a-string enc)
Calls URLEncoder.encode on a-string with encoding, UTF-8 by default.
Calls URLEncoder.encode on a-string with encoding, UTF-8 by default.
(url-encode-path a-path)
URL-encode given path as UTF-8, element by element.
URL-encode given path as UTF-8, element by element.
Map of keywords to FileVisitOption enums.
Map of keywords to FileVisitOption enums.
(visit-opts)
(visit-opts options)
Accepts opts, keywords are subbed with file-visit-option, others passed on.
Accepts opts, keywords are subbed with file-visit-option, others passed on.
(writable? a-path)
Czech of resulting Path is writable via Files/isWritable call.
Czech of resulting Path is writable via Files/isWritable call.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close