Liking cljdoc? Tell your friends :D

hara.io.file


attributesclj

(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}
raw docstring

codeclj

(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)
raw docstring

copyclj

(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")
raw docstring

copy-singleclj

(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")
raw docstring

create-directoryclj

(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")
raw docstring

(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

raw docstring

create-tmpdirclj

(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"
raw docstring

deleteclj

(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?
raw docstring

directory?clj

(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
raw docstring

empty-directory?clj

(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
raw docstring

executable?clj

(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
raw docstring

exists?clj

(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
raw docstring

fileclj

(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"
raw docstring

file-typeclj

(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
raw docstring

file?clj

(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
raw docstring

hidden?clj

(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
raw docstring

input-streamclj

(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")
raw docstring

link?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
raw docstring

listclj

(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--/-"}
raw docstring

moveclj

(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")
=> {}
raw docstring

optionclj

(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
raw docstring

output-streamclj

(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")
raw docstring

parentclj

(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"
raw docstring

pathclj

(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"
raw docstring

path?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
raw docstring

permissionsclj

(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"
raw docstring

read-all-bytesclj

(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")
raw docstring

read-all-linesclj

(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")
raw docstring

readable?clj

(readable? path)

checks whether a file is readable

(readable? "project.clj") => true

checks whether a file is readable

(readable? "project.clj")
=> true
raw docstring

readerclj

(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
raw docstring

reader-typesclj

(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])
raw docstring

relativizeclj

(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"
raw docstring

sectionclj

(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"
raw docstring

selectclj

(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"]
raw docstring

set-attributesclj

(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"
raw docstring

shorthandclj

(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")
=> "-"
raw docstring

to-fileclj

(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")))
raw docstring

writable?clj

(writable? path)

checks whether a file is writable

(writable? "project.clj") => true

checks whether a file is writable

(writable? "project.clj")
=> true
raw docstring

writeclj

(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}}))
raw docstring

write-all-bytesclj

(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"))
raw docstring

writerclj

(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"

raw docstring

writer-typesclj

(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)
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close