Namespace

DuPath

DuPath

Paths related methods

View Source DuAEF_Duik_api.jsxinc, line 508

Members

string

# static readonly SizeUnit

Units to use for sizes.
Properties:
Name Type Description
BIT string
BYTE string
KB string
MB string
GB string
TB string

View Source DuAEF_Duik_api.jsxinc, line 515

Methods

# static fixName(name, placeholderopt) → {string}

Removes all forbidden characters from a string to be used as a filename
Parameters:
Name Type Attributes Default Description
name string The filename to fix
placeholder string <optional>
'.' The string used to replace the forbidden characters

View Source DuAEF_Duik_api.jsxinc, line 697

The fixed filename
string

# static getBasename(pathOrFileopt) → {String}

Returns the basename of the given path or file
Parameters:
Name Type Attributes Description
pathOrFile String | File <optional>
The file or the path

View Source DuAEF_Duik_api.jsxinc, line 600

The basename
String
Example
DuPath.getBasename(new File("D:/code/open/Duik/shape.test")) // "shape"
DuPath.getBasename("D:/code/open/Duik/shape.test") // "shape"

# static getExtension(pathOrFileopt) → {String}

Returns the extension of the given path or file
Parameters:
Name Type Attributes Description
pathOrFile String | File <optional>
The file or the path

View Source DuAEF_Duik_api.jsxinc, line 621

The extension
String
Example
DuPath.getExtension(new File("D:/code/open/Duik/shape.other.test")) // "test"
DuPath.getExtension("D:/code/open/Duik/shape.test") // "test"

# static getName(pathOrFileopt) → {String}

Returns the name of the given path or file, as displayed by the filesystem
Parameters:
Name Type Attributes Description
pathOrFile String | File | Folder <optional>
The file or the path

View Source DuAEF_Duik_api.jsxinc, line 580

The basename
String
Example
DuPath.getName(new File("D:\\code\\open\\Duik\\shape test.test")) // "shape test.test"
DuPath.getName("D:/code/open/Duik/other shape.test") // "other shape.test"

# static incrementName(file) → {string}

Increments the last number before the extension in a filename
Parameters:
Name Type Description
file File The file

View Source DuAEF_Duik_api.jsxinc, line 668

The incremented fileName
string

# static isFile(path) → {bool}

Checks if the given path represents an existing file
Parameters:
Name Type Description
path File | Folder | string The path to check

View Source DuAEF_Duik_api.jsxinc, line 708

bool

# static isFolder(path) → {bool}

Checks if the given path represents an existing folder
Parameters:
Name Type Description
path File | Folder | string The path to check

View Source DuAEF_Duik_api.jsxinc, line 724

bool

# static join(partsopt, sepopt) → {String}

Joins multiple paths togetther.
Parameters:
Name Type Attributes Default Description
parts Array.<string> <optional>
The parts to join togehter
sep String <optional>
"/" The separator to use. If not defined, will look for the first sep in the path.

View Source DuAEF_Duik_api.jsxinc, line 530

The final path
String

# static newUniqueName(newName, folder, incrementopt) → {string}

Generates a new unique name for a file
Parameters:
Name Type Attributes Default Description
newName string The wanted new name
folder Folder The folder
increment boolean <optional>
true true to automatically increment the new name if it already ends with a digit

View Source DuAEF_Duik_api.jsxinc, line 654

The unique name, with a new number at the end if needed.
string

# static sizeFromBytes(size, toopt, decimalsopt) → {float}

Converts a number of Bytes to kB or MB or GB or TB For conversion to bits, a Byte is considered to be 8 bits.
Parameters:
Name Type Attributes Default Description
size int The size in Bytes to convert
to DuPath.SizeUnit <optional>
DuPath.SizeUnit.MB The unit to convert to, one of: b, kB, MB, GB, TB
decimals int <optional>
2 The number of decimals to round the result

View Source DuAEF_Duik_api.jsxinc, line 552

The result of the conversion
float

# static switchExtension(pathOrFileopt, newExtensionopt) → {String}

Switch the extension of the given path. Create a new path from a given path and a given extension.
Parameters:
Name Type Attributes Description
pathOrFile String | File <optional>
The file or the path
newExtension String <optional>
The new extension

View Source DuAEF_Duik_api.jsxinc, line 637

The new path
String