Well typed and flexible file systems paths, preserving the OS and filesystem
encoding.
You can choose the level of type safety you want. Path is the basic path
type which can represent a file, directory, absolute or relative path with
no restrictions. Depending on how much type safety you want you can choose
appropriate type wrappers to wrap Path. File Path mandates the path to
be a file whereas Abs (File Path) mandates it to be an absolute path
representing a file.
You can upgrade or downgrade the safety. Whenever a less restrictive path
type is converted to a more restrctive path type the conversion involves
checks and it may fail. However, a more restrictive path type can be freely
converted to a less restrictive one.
See the streamly-filepath package for interworking with the OsPath type.
The Path type can be converted to and from OsPath type at zero cost
since the underlying representation of both is the same.
Like fromPath but does not check the properties of Path. Provides
performance and simplicity when we know that the properties of the path
are already verified, for example, when we get the path from the file
system or the OS APIs.
Convert a path type to another path type. This operation may fail with a
PathException when converting a less restrictive path type to a more
restrictive one.
On Posix it may fail if the byte array contains null characters. On
Windows the array passed must be a multiple of 2 bytes as the underlying
representation uses Word16.
Unsafe: On Posix, a path cannot contain null characters. On Windows, the
array passed must be a multiple of 2 bytes as the underlying representation
uses Word16.
Encode a Unicode string to Path using strict UTF-8 encoding on Posix.
On Posix it may fail if the stream contains null characters.
TBD: Use UTF16LE on Windows.
Encode a Unicode char stream to Path using strict UTF-8 encoding on
Posix. On Posix it may fail if the stream contains null characters.
TBD: Use UTF16LE on Windows.
Primary path separator character, / on Posix and \ on Windows.
Windows supports / too as a separator. Please use isSeparator for
testing if a char is a separator char.
Like extendDir but for the less restrictive Path type which will always
create a syntactically valid Path type but it may not be semantically valid
because we may append an absolute path or we may append to a file path.
The onus lies on the user to ensure that the first path is not a file and
the second path is not absolute.