(attributes path)
shows all attributes for a given path (attributes "project.clj") => {:owner "chris", :group "staff", :permissions "rw-r--r--", :file-key "(dev=1000004,ino=2351455)", :ino 2351455, :is-regular-file true. :is-directory false, :uid 501, :is-other false, :mode 33188, :size 4342, :gid 20, :ctime 1476755481000, :nlink 1, :last-access-time 1476755481000, :is-symbolic-link false, :last-modified-time 1476755481000, :creation-time 1472282953000,
:dev 16777220, :rdev 0}
shows all attributes for a given path (attributes "project.clj") => {:owner "chris", :group "staff", :permissions "rw-r--r--", :file-key "(dev=1000004,ino=2351455)", :ino 2351455, :is-regular-file true. :is-directory false, :uid 501, :is-other false, :mode 33188, :size 4342, :gid 20, :ctime 1476755481000, :nlink 1, :last-access-time 1476755481000, :is-symbolic-link false, :last-modified-time 1476755481000, :creation-time 1472282953000, :dev 16777220, :rdev 0}
(code path)
takes a file and returns a lazy seq of top-level forms
(->> (code "../hara/src/hara/io/file.clj") first (take 2)) => '(ns hara.io.file)
takes a file and returns a lazy seq of top-level forms (->> (code "../hara/src/hara/io/file.clj") first (take 2)) => '(ns hara.io.file)
(copy source target)
(copy source target opts)
copies all specified files from one to another
(copy "src" ".src" {:include [".clj"]})
=> map?
(delete ".src")
copies all specified files from one to another (copy "src" ".src" {:include [".clj"]}) => map? (delete ".src")
(copy-single source target)
(copy-single source target opts)
copies a single file to a destination
(copy-single "project.clj" "project.clj.bak" {:options #{:replace-existing}}) ;;=> #path:"/Users/chris/Development/chit/hara/project.clj.bak"
(delete "project.clj.bak")
copies a single file to a destination (copy-single "project.clj" "project.clj.bak" {:options #{:replace-existing}}) ;;=> #path:"/Users/chris/Development/chit/hara/project.clj.bak" (delete "project.clj.bak")
(create-directory path)
(create-directory path attrs)
creates a directory on the filesystem
(do (create-directory ".hello/.world/.foo") (directory? ".hello/.world/.foo")) => true
(delete ".hello/.world/.foo")
creates a directory on the filesystem (do (create-directory ".hello/.world/.foo") (directory? ".hello/.world/.foo")) => true (delete ".hello/.world/.foo")
(create-symlink path link-to)
(create-symlink path link-to attrs)
creates a symlink to another file
(do (create-symlink "project.lnk" "project.clj") (link? "project.lnk")) => true
creates a symlink to another file (do (create-symlink "project.lnk" "project.clj") (link? "project.lnk")) => true
(create-tmpdir)
(create-tmpdir prefix)
creates a temp directory on the filesystem
(create-tmpdir) ;;=> #path:"/var/folders/d6/yrjldmsd4jd1h0nm970wmzl40000gn/T/4870108199331749225"
creates a temp directory on the filesystem (create-tmpdir) ;;=> #path:"/var/folders/d6/yrjldmsd4jd1h0nm970wmzl40000gn/T/4870108199331749225"
(delete root)
(delete root opts)
copies all specified files from one to another
(do (copy "src" ".src" {:include [".clj"]}) (delete ".src" {:include ["test.clj"]})) => #{(str (path ".src/hara/test.clj"))}
(delete ".src") => set?
copies all specified files from one to another (do (copy "src" ".src" {:include [".clj"]}) (delete ".src" {:include ["test.clj"]})) => #{(str (path ".src/hara/test.clj"))} (delete ".src") => set?
(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") => false
(executable? "/usr/bin/whoami") => true
checks whether a file is executable (executable? "project.clj") => false (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)
opens a file and reads the contents as an array of lines
(file "project.clj") ;;=> #file:"../spirit/project.clj"
opens a file and reads the contents as an array of lines (file "project.clj") ;;=> #file:"../spirit/project.clj"
(file-type file)
encodes the type of file as a keyword
(file-type "hello.clj") => :clj
(file-type "hello.java") => :java
encodes the type of file as a keyword (file-type "hello.clj") => :clj (file-type "hello.java") => :java
(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")
(link? path)
checks whether a file is a link
(link? "project.clj") => false
(delete "project.bak.clj") (link? (create-symlink "project.bak.clj" "project.clj")) => true
checks whether a file is a link (link? "project.clj") => false (delete "project.bak.clj") (link? (create-symlink "project.bak.clj" "project.clj")) => true
(list root)
(list root opts)
lists the files and attributes for a given directory
(list "src") => {"/Users/chris/Development/chit/hara/src" "rwxr-xr-x/d", "/Users/chris/Development/chit/hara/src/hara" "rwxr-xr-x/d"}
(list "../hara/src/hara/io" {:recursive true}) => {"/Users/chris/Development/chit/hara/src/hara/io" "rwxr-xr-x/d", "/Users/chris/Development/chit/hara/src/hara/io/file/reader.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/project.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file/filter.clj" "rw-r--r--/-", ... ... "/Users/chris/Development/chit/hara/src/hara/io/file/path.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file/walk.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file.clj" "rw-r--r--/-"}
lists the files and attributes for a given directory (list "src") => {"/Users/chris/Development/chit/hara/src" "rwxr-xr-x/d", "/Users/chris/Development/chit/hara/src/hara" "rwxr-xr-x/d"} (list "../hara/src/hara/io" {:recursive true}) => {"/Users/chris/Development/chit/hara/src/hara/io" "rwxr-xr-x/d", "/Users/chris/Development/chit/hara/src/hara/io/file/reader.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/project.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file/filter.clj" "rw-r--r--/-", ... ... "/Users/chris/Development/chit/hara/src/hara/io/file/path.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file/walk.clj" "rw-r--r--/-", "/Users/chris/Development/chit/hara/src/hara/io/file.clj" "rw-r--r--/-"}
(move source target)
(move source target opts)
moves a file or directory
(do (move "shortlist" ".shortlist") (move ".shortlist" "shortlist"))
(move ".non-existent" ".moved") => {}
moves a file or directory (do (move "shortlist" ".shortlist") (move ".shortlist" "shortlist")) (move ".non-existent" ".moved") => {}
(option)
(option k)
shows all options for file operations
(option) => (contains [:atomic-move :create-new :skip-siblings :read :continue :create :terminate :copy-attributes :append :truncate-existing :sync :follow-links :delete-on-close :write :dsync :replace-existing :sparse :nofollow-links :skip-subtree])
(option :read) => java.nio.file.StandardOpenOption/READ
shows all options for file operations (option) => (contains [:atomic-move :create-new :skip-siblings :read :continue :create :terminate :copy-attributes :append :truncate-existing :sync :follow-links :delete-on-close :write :dsync :replace-existing :sparse :nofollow-links :skip-subtree]) (option :read) => java.nio.file.StandardOpenOption/READ
(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 path)
returns the parent of the path
(str (parent "/hello/world.html")) => "/hello"
returns the parent of the path (str (parent "/hello/world.html")) => "/hello"
(path x)
(path s & more)
creates a `java.nio.file.Path object
(path "project.clj") ;;=> #path:"/Users/chris/Development/chit/hara/project.clj"
(path (path "project.clj")) ;; idempotent ;;=> #path:"/Users/chris/Development/chit/hara/project.clj"
(path "~") ;; tilda ;;=> #path:"/Users/chris"
(path "src" "hara/time.clj") ;; multiple arguments ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj"
(path ["src" "hara" "time.clj"]) ;; vector ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj"
(path (java.io.File. ;; java.io.File object "src/hara/time.clj")) ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj"
(path (java.net.URI. ;; java.net.URI object "file:///Users/chris/Development/chit/hara/project.clj")) ;;=> #path:"/Users/chris/Development/chit/hara/project.clj"
creates a `java.nio.file.Path object (path "project.clj") ;;=> #path:"/Users/chris/Development/chit/hara/project.clj" (path (path "project.clj")) ;; idempotent ;;=> #path:"/Users/chris/Development/chit/hara/project.clj" (path "~") ;; tilda ;;=> #path:"/Users/chris" (path "src" "hara/time.clj") ;; multiple arguments ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj" (path ["src" "hara" "time.clj"]) ;; vector ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj" (path (java.io.File. ;; java.io.File object "src/hara/time.clj")) ;;=> #path:"/Users/chris/Development/chit/hara/src/hara/time.clj" (path (java.net.URI. ;; java.net.URI object "file:///Users/chris/Development/chit/hara/project.clj")) ;;=> #path:"/Users/chris/Development/chit/hara/project.clj"
(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
(reader input)
(reader type input)
(reader type input opts)
creates a reader for a given input
(-> (reader :pushback "project.clj") (read) second) => 'zcaudate/hara
creates a reader for a given input (-> (reader :pushback "project.clj") (read) second) => 'zcaudate/hara
(reader-types)
returns the types of readers
(reader-types) => (contains [:input-stream :buffered :file :string :pushback :char-array :piped :line-number])
returns the types of readers (reader-types) => (contains [:input-stream :buffered :file :string :pushback :char-array :piped :line-number])
(relativize path1 path2)
returns the relationship between two paths
(str (relativize "hello" "hello/world.html")) => "world.html"
returns the relationship between two paths (str (relativize "hello" "hello/world.html")) => "world.html"
(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"
(select root)
(select root opts)
selects all the files in a directory
(->> (select "../hara/src/hara/io/file" ) (map #(relativize "../hara/src/hara" %)) (map str) (sort)) => ["io/file" "io/file/attribute.clj" "io/file/common.clj" "io/file/filter.clj" "io/file/option.clj" "io/file/path.clj" "io/file/reader.clj" "io/file/walk.clj"]
selects all the files in a directory (->> (select "../hara/src/hara/io/file" ) (map #(relativize "../hara/src/hara" %)) (map str) (sort)) => ["io/file" "io/file/attribute.clj" "io/file/common.clj" "io/file/filter.clj" "io/file/option.clj" "io/file/path.clj" "io/file/reader.clj" "io/file/walk.clj"]
(set-attributes path m)
sets all attributes for a given path
(set-attributes "project.clj" {:owner "chris", :group "staff", :permissions "rw-rw-rw-"}) ;;=> #path:"/Users/chris/Development/chit/lucidity/project.clj"
sets all attributes for a given path (set-attributes "project.clj" {:owner "chris", :group "staff", :permissions "rw-rw-rw-"}) ;;=> #path:"/Users/chris/Development/chit/lucidity/project.clj"
(shorthand path)
returns the shorthand string for a given entry
(shorthand "src") => "d"
(shorthand "project.clj") => "-"
returns the shorthand string for a given entry (shorthand "src") => "d" (shorthand "project.clj") => "-"
(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")))
(writable? path)
checks whether a file is writable
(writable? "project.clj") => true
checks whether a file is writable (writable? "project.clj") => true
(write stream path)
(write stream path opts)
writes a stream to a path
(-> (java.io.FileInputStream. "project.clj") (write "project.clj" {:options #{:replace-existing}}))
writes a stream to a path (-> (java.io.FileInputStream. "project.clj") (write "project.clj" {:options #{:replace-existing}}))
(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"))
(writer opts)
(writer type opts)
creates a writer given options
(doto (writer :buffered {:path "hello.txt"}) (.write "Hello" 0 4) (.write "World" 0 4) (.close))
(slurp "hello.txt") => "HellWorl"
creates a writer given options (doto (writer :buffered {:path "hello.txt"}) (.write "Hello" 0 4) (.write "World" 0 4) (.close)) (slurp "hello.txt") => "HellWorl"
(writer-types)
returns the types of writers
(writer-types) => (contains [:buffered :char-array :file :output-stream :piped :print :string] :in-any-order)
returns the types of writers (writer-types) => (contains [:buffered :char-array :file :output-stream :piped :print :string] :in-any-order)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close