Header menu logo issie

PathHelpers Module

Pure path arithmetic, shared by the Fable and .NET builds. These were node's `path` under Fable and System.IO.Path under .NET - two implementations that already disagreed (node's join normalises, Path.Join does not), and one of which disappears with contextIsolation since `path` is a node module the renderer will not be able to require. Joining strings is not a privileged operation and has no business crossing a process boundary, so rather than becoming ten more bridge calls at 189 call sites this is one implementation for both targets. It follows node's semantics, which is what the app was built against, and Tests/Issie.Tests/PathHelperTests.fs holds it to them. Separator handling is platform-dependent in the way node's is: on Windows both `/` and `\` divide segments and output uses `\`; on POSIX only `/` divides and a backslash is an ordinary filename character. The leading root - a drive, a UNC share, or `/` - is found but never rewritten by dirname and basename, because node does not rewrite it either, and UNC paths matter here: Issie is run from networked locations on cluster machines.

Functions and values

Function or value Description

basename p

Full Usage: basename p

Parameters:
    p : string

Returns: string

node's path.basename: trailing separators are ignored, then everything after the last one. The root has no basename, so "C:\" and "/" give "".

p : string
Returns: string

dirname p

Full Usage: dirname p

Parameters:
    p : string

Returns: string

node's path.dirname. Separators inside the path are left exactly as they were found - node does not normalise here, and neither does this.

p : string
Returns: string

extname p

Full Usage: extname p

Parameters:
    p : string

Returns: string

node's path.extname: from the last dot in the basename, when that dot is not the first character. So "a.txt" gives ".txt", "a.b.c" gives ".c", and a dotfile like ".gitignore" gives "".

p : string
Returns: string

isAbsolute p

Full Usage: isAbsolute p

Parameters:
    p : string

Returns: bool

True when the path starts from a root rather than from wherever the process happens to be. A bare drive is not absolute: "C:" and "C:a" are both relative to that drive's working directory.

p : string
Returns: bool

isSeparator c

Full Usage: isSeparator c

Parameters:
    c : char

Returns: bool
c : char
Returns: bool

join parts

Full Usage: join parts

Parameters:
    parts : string array

Returns: string

node's path.join: empty parts are dropped, the rest are joined and the result normalised.

parts : string array
Returns: string

normalise p

Full Usage: normalise p

Parameters:
    p : string

Returns: string

node's path.normalize: collapse `.` and `..`, squeeze repeated separators, and write the platform's separator throughout. A trailing separator is kept, as node keeps it.

p : string
Returns: string

sepChar

Full Usage: sepChar

Returns: char

The separator this platform writes.

Returns: char

Type something to start searching.