Liking cljdoc? Tell your friends :D

hara.io.file.path


*empty-string-array*clj


file-nameclj

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

file-systemclj

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

normaliseclj

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

nth-segmentclj

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

parentclj

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

relativizeclj

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

rootclj

(root x)

returns the root path

(str (root "/usr/local/bin")) => "/"

returns the root path

(str (root "/usr/local/bin"))
=> "/"
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

segment-countclj

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

subpathclj

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

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

× close