(directory? path)checks whether a file is a directory
(directory? "src") => true
(directory? "project.clj") => false
checks whether a file is a directory (directory? "src") => true (directory? "project.clj") => false
(empty-directory? path)checks if a directory is empty, returns true if both are true
(empty-directory? ".") => false
checks if a directory is empty, returns true if both are true (empty-directory? ".") => false
(executable? path)checks whether a file is executable
(executable? "project.clj") => boolean?
(executable? "/usr/bin/whoami") => true
checks whether a file is executable (executable? "project.clj") => boolean? (executable? "/usr/bin/whoami") => true
(exists? path)checks whether a file exists
(exists? "project.clj") => true
(exists? "NON.EXISTENT") => false
checks whether a file exists (exists? "project.clj") => true (exists? "NON.EXISTENT") => false
(file path)returns the input as a file
(file "project.clj") => java.io.File
returns the input as a file (file "project.clj") => java.io.File
(file-name x)returns the last section of the path
(str (file-name "src/hara")) => "hara"
returns the last section of the path (str (file-name "src/hara")) => "hara"
(file-suffix file)encodes the type of file as a keyword
(file-suffix "hello.clj") => :clj
(file-suffix "hello.java") => :java
encodes the type of file as a keyword (file-suffix "hello.clj") => :clj (file-suffix "hello.java") => :java
(file-system x)returns the filesystem governing the path
(file-system ".") ;; #object[sun.nio.fs.MacOSXFileSystem 0x512a9870 "sun.nio.fs.MacOSXFileSystem@512a9870"] => java.nio.file.FileSystem
returns the filesystem governing the path (file-system ".") ;; #object[sun.nio.fs.MacOSXFileSystem 0x512a9870 "sun.nio.fs.MacOSXFileSystem@512a9870"] => java.nio.file.FileSystem
(file? path)checks whether a file is not a link or directory
(file? "project.clj") => true
(file? "src") => false
checks whether a file is not a link or directory (file? "project.clj") => true (file? "src") => false
(hidden? path)checks whether a file is hidden
(hidden? ".gitignore") => true
(hidden? "project.clj") => false
checks whether a file is hidden (hidden? ".gitignore") => true (hidden? "project.clj") => false
(input-stream path)(input-stream path opts)opens a file as an input-stream
(input-stream "project.clj")
opens a file as an input-stream (input-stream "project.clj")
(last-modified path)returns the last modified time as a long
(last-modified "project.clj") => integer?
returns the last modified time as a long (last-modified "project.clj") => integer?
(link? path)checks whether a file is a link
(link? "project.clj") => false
(link? (api/create-symlink "project.lnk" "project.clj")) => true (api/delete "project.lnk")
checks whether a file is a link
(link? "project.clj")
=> false
(link? (api/create-symlink "project.lnk"
"project.clj"))
=> true
(api/delete "project.lnk")(normalise s)creates a string that takes notice of the user home
(normalise ".") => (str common/cwd "/" ".")
(normalise "~/hello/world.txt") => (str common/home "/hello/world.txt")
(normalise "/usr/home") => "/usr/home"
creates a string that takes notice of the user home (normalise ".") => (str common/*cwd* "/" ".") (normalise "~/hello/world.txt") => (str common/*home* "/hello/world.txt") (normalise "/usr/home") => "/usr/home"
(nth-segment x i)returns the nth segment of a given path
(str (nth-segment "/usr/local/bin" 1)) => "local"
returns the nth segment of a given path (str (nth-segment "/usr/local/bin" 1)) => "local"
(output-stream path)(output-stream path opts)opens a file as an output-stream
(output-stream "project.clj")
opens a file as an output-stream (output-stream "project.clj")
(parent x)returns the parent of the given path
(str (parent "/usr/local/bin")) => "/usr/local"
returns the parent of the given path (str (parent "/usr/local/bin")) => "/usr/local"
(path x)(path s & more)creates a `java.nio.file.Path object
creates a `java.nio.file.Path object
(path? x)checks to see if the object is of type Path
(path? (path "/home")) => true
checks to see if the object is of type Path (path? (path "/home")) => true
(permissions path)returns the permissions for a given file
(permissions "src") => "rwxr-xr-x"
returns the permissions for a given file (permissions "src") => "rwxr-xr-x"
(read-all-bytes path)opens a file and reads the contents as a byte array
(read-all-bytes "project.clj")
opens a file and reads the contents as a byte array (read-all-bytes "project.clj")
(read-all-lines path)opens a file and reads the contents as an array of lines
(read-all-lines "project.clj")
opens a file and reads the contents as an array of lines (read-all-lines "project.clj")
(readable? path)checks whether a file is readable
(readable? "project.clj") => true
checks whether a file is readable (readable? "project.clj") => true
(relativize x other)returns one path relative to another
(str (relativize "test" "src/hara")) => "../src/hara"
returns one path relative to another (str (relativize "test" "src/hara")) => "../src/hara"
(root x)returns the root path
(str (root "/usr/local/bin")) => "/"
returns the root path (str (root "/usr/local/bin")) => "/"
(section s & more)path object without normalisation
(str (section "project.clj")) => "project.clj"
(str (section "src" "hara/time.clj")) => "src/hara/time.clj"
path object without normalisation (str (section "project.clj")) => "project.clj" (str (section "src" "hara/time.clj")) => "src/hara/time.clj"
(segment-count x)returns the number of segments of a given path
(segment-count "/usr/local/bin") => 3
returns the number of segments of a given path (segment-count "/usr/local/bin") => 3
(set-executable path)sets a file to be executable
sets a file to be executable
(subpath x start end)returns the subpath of a given path
(str (subpath "/usr/local/bin/hello" 1 3)) => "local/bin"
returns the subpath of a given path (str (subpath "/usr/local/bin/hello" 1 3)) => "local/bin"
(to-file path)creates a java.io.File object
(to-file (section "project.clj")) => (all java.io.File #(-> % str (= "project.clj")))
creates a java.io.File object
(to-file (section "project.clj"))
=> (all java.io.File
#(-> % str (= "project.clj")))(typestring path)returns the shorthand string for a given entry
(typestring "src") => "d"
(typestring "project.clj") => "-"
returns the shorthand string for a given entry (typestring "src") => "d" (typestring "project.clj") => "-"
(writable? path)checks whether a file is writable
(writable? "project.clj") => true
checks whether a file is writable (writable? "project.clj") => true
(write-all-bytes path bytes)(write-all-bytes path bytes opts)writes a byte-array to file
(write-all-bytes "hello.txt" (.getBytes "Hello World"))
writes a byte-array to file (write-all-bytes "hello.txt" (.getBytes "Hello World"))
(write-into path stream)(write-into path stream opts)writes a stream to a path
(write-into "project.clj" (java.io.FileInputStream. "project.clj") {:options #{:replace-existing}})
writes a stream to a path
(write-into "project.clj" (java.io.FileInputStream. "project.clj")
{:options #{:replace-existing}})cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |