FilePath

laika.io.model.FilePath
See theFilePath companion object
class FilePath extends GenericPath

Represents an absolute path on the file system, pointing to a file or directory that may or may not exist. Relative paths are interpreted as relative to the current working directory.

This type has a lot of shared API with the VirtualPath abstraction in laika-core via their common super-trait GenericPath. Like the virtual path API it comes with convenience methods for querying and modifying suffix and fragment components, a common requirement in processing internal links for example.

However, it differs in three ways from the virtual path abstraction: first, semantically, as the latter is never intended to represent an actual file and instead just describes a tree structure of inputs (and AST documents after parsing).

Secondly, this type comes with additional APIs to convert to and from other path representations, namely java.io.File, java.nio.file.Path and fs2.io.file.Path.

And finally, the toString method for this type returns a platform-dependent string representation by using the file separator of the underlying file system. Laika's virtual path abstractions on the other hand always uses a forward slash / as the separator.

Having a dedicated file path abstraction also helps with type signatures for methods in Laika's APIs that accept two path arguments: a file path and a virtual path indicating the mount point (at which the specified file is supposed to be inserted into the virtual tree).

Attributes

Companion
object
Graph
Supertypes
trait GenericPath
class Object
trait Matchable
class Any

Members list

Type members

Types

type Self = FilePath

Value members

Concrete methods

override def /(name: String): FilePath

Creates a new path with the specified name as an immediate child of this path.

Creates a new path with the specified name as an immediate child of this path.

Attributes

Definition Classes
GenericPath
def /(path: RelativePath): FilePath

Combines this path with the specified relative path.

Combines this path with the specified relative path.

Attributes

override def equals(other: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
def fragment: Option[String]

The fragment part of the path (after a # in the last segment), or None if this path does not have a fragment component.

The fragment part of the path (after a # in the last segment), or None if this path does not have a fragment component.

Attributes

override def hashCode(): Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
def name: String

The local name of this path, without the optional fragment part, but including the suffix if present.

The local name of this path, without the optional fragment part, but including the suffix if present.

Attributes

def suffix: Option[String]

The suffix of None if this path name does not have a file suffix separated by a ..

The suffix of None if this path name does not have a file suffix separated by a ..

Attributes

def toFS2Path: Path

Converts this FilePath to an fs2.io.file.Path.

Converts this FilePath to an fs2.io.file.Path.

Attributes

def toJavaFile: File

Converts this FilePath to an java.io.File instance.

Converts this FilePath to an java.io.File instance.

Attributes

def toNioPath: Path

Converts this FilePath to a java.nio.file.Path.

Converts this FilePath to a java.nio.file.Path.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Inherited methods

def withBasename(name: String): Self

Returns a new path that replaces the base name with the specified new name while keeping both, suffix and fragment, in case they are present.

Returns a new path that replaces the base name with the specified new name while keeping both, suffix and fragment, in case they are present.

Attributes

Inherited from:
GenericPath
def withFragment(fragment: String): Self

Returns a new path that either replaces the existing fragment component with the specified one or appends it if this path does not have a component yet.

Returns a new path that either replaces the existing fragment component with the specified one or appends it if this path does not have a component yet.

Attributes

Inherited from:
GenericPath
def withSuffix(suffix: String): Self

Returns a new path that either replaces the existing suffix with the specified one or appends it if this path does not have a suffix yet.

Returns a new path that either replaces the existing suffix with the specified one or appends it if this path does not have a suffix yet.

Attributes

Inherited from:
GenericPath
def withoutFragment: Self

Returns a new path that discards this path's fragment, if present.

Returns a new path that discards this path's fragment, if present.

Attributes

Inherited from:
GenericPath
def withoutSuffix: Self

Returns a new path that discards this path's suffix, if present.

Returns a new path that discards this path's suffix, if present.

Attributes

Inherited from:
GenericPath

Concrete fields

override val basename: String

The base name of this path, without the suffix (if present).

The base name of this path, without the suffix (if present).

Attributes

val isAbsolute: Boolean

Indicates whether this path is absolute. Relative paths are interpreted relative to the current working directory during a transformation.

Indicates whether this path is absolute. Relative paths are interpreted relative to the current working directory during a transformation.

Attributes