(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-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
(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"
(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
(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
(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
(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")))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close