_methods
J.Path represents a directory or file in the File.System, which may or may not exist
Path implements Idx, representing directory names hierarchy. The last name may be a name of file, if Path is for file
Path may or may not have root (like C:). This may be checked with rootOpt
A void Path has no root and zero directories
NaturalOrderingly, a 'rootless' path can be added to another path in order to extend it
Path with a root can only be extended itself
val p1 = J.Path("aaa", "bbb").rootMake
val p2 = J.Path("ccc", "ddd")
p1 tp // Prints: C:\aaa\bbb
p2 tp // Prints: ccc\ddd
p1 + p2 + "xyz" tp // Prints: C:\aaa\bbb\ccc\ddd\xyz
p2 + p1 // App.Fail$Message: Cannot extend with root: C:\aaa\bbb
- Source
- _methods.scala
Def
Checks end match
Checks end match
Returns true
if this
Path ends with p
val path: J.Path = "aaa" , "bbb" + "ccc" + "ddd"
path endsWith "ccc" , "ddd".tp // Prints: true
path endsWith "aaa" , "bbb".tp // Prints: false
- Source
- _methods.scala
Check exists
Check exists
Returns true
this
Path exists in the file system as file or directory
- Source
- _methods.scala
Sub-path index
Sub-path index
Optionally returns matching sub-path start index
val path: J.Path = "aaa" , "bbb" + "ccc" + "ddd" + "eee"
path indexOpt "ccc" , "ddd" tp // Prints: Opt(2)
path indexOpt "ddd" , "ccc" tp // Prints: Opt(VOID)
- Source
- _methods.scala
Last name
Last name
Returns last name in the Path hierarchy
If this Path points to a file, lastName
is the name of file
val path : J.Path = "Temp" , "Test.txt"
path.lastName tp // Prints: Test.txt
- Source
- _methods.scala
Parent Path
Parent Path
Returns parent Path of this
Path
val p: J.Path = "aaa" , "bbb" + "ccc"
p.parent tp // Prints: aaa\bbb
- Source
- _methods.scala
Looses root if any
Looses root if any
If this
Path has a root, new Path without root is returned
Otherwise this
Path is returned as is
val p = J.Path("aaa" , "bbb").rootMake
p tp // May print: C:\aaa\bbb
p.rootDrop tp // May print: aaa\bbb
- Source
- _methods.scala
Makes root if none
Makes root if none
If this
Path has no root, new Path with current root is returned
Otherwise this
Path is returned as is
val p: J.Path = "aaa" , "bbb"
p tp // May print: aaa\bbb
p.rootMake tp // May print: C:\aaa\bbb
- Source
- _methods.scala
Optional root
Optional root
Optionally returns root Path if available
val p = J.Path("aaa" , "bbb").rootMake
p.rootOpt tp // May print: Opt(C:\)
p.rootDrop.rootOpt.tp // prints: Opt(VOID)
- Source
- _methods.scala
Checks start match
Checks start match
Returns true
if this
Path starts with p
val path: J.Path = "aaa" , "bbb" + "ccc" + "ddd"
path startsWith "aaa" , "bbb" tp // Prints: true
path startsWith "bbb" , "aaa" tp // Prints: false
- Source
- _methods.scala
Sub-path after
Sub-path after
Returns sub-path after p
- Value Params
- default
path if
p
is not found. If not specified, default is the original pathval p: J.Path = "aaa" , "bbb" + "ccc" + "ddd" + "eee" + "fff" p tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathAfter "ccc" , "ddd" tp // Prints: eee\fff p subpathAfter "ddd" , "ccc" tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathAfter ("ddd" , "ccc", "xyz" , "bbc") tp // Prints: xyz\bbc
- p
sub-path to copy after
- Source
- _methods.scala
Sub-path before
Sub-path before
Returns sub-path from start to p
- Value Params
- default
path if
p
is not found. If not specified, default is the original pathval p: J.Path = "aaa" , "bbb" + "ccc" + "ddd" + "eee" + "fff" p tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathBefore "ccc" , "ddd" tp // Prints: aaa\bbb p subpathBefore "ddd" , "ccc" tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathBefore ("ddd" , "ccc", "xyz" , "bbc") tp // Prints: xyz\bbc
- p
sub-path to copy up to
- Source
- _methods.scala
Sub-path from
Sub-path from
Returns sub-path starting from specified Path
- Value Params
- default
path if
p
is not found. If not specified, default is the original pathval p: J.Path = "aaa" , "bbb" + "ccc" + "ddd" + "eee" + "fff" p tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathFrom "ccc" , "ddd" tp // Prints: ccc\ddd\eee\fff p subpathFrom "ddd" , "ccc" tp // Prints: aaa\bbb\ccc\ddd\eee\fff p subpathFrom ("ddd" , "ccc", "xyz" , "bbc").tp // Prints: xyz\bbc
- p
sub-path to copy from
- Source
- _methods.scala