Under development — the help is being filled in plugin by plugin.
Plugin reference

path

Pure string helpers for filesystem paths — never touches the disk.

5 functionsnamespace pathsource plugins/path/PathPlugin.c

Written from a line-by-line source review; every example output is from a real run (Linux).

Introduction

The path plugin provides textual handling of file paths: you can safely join two path parts, extract the directory or the file name from a path, decide whether a path is absolute, and normalize a path (removing the redundant parts). The plugin performs purely textual operations — it does not touch the file system, and does not check whether the path exists. The plugin is stateless, every call is standalone.

Cross-platform separators

The plugin uses the running system's path separator: the slash (/) on Linux, the backslash (\) on Windows. Joining inserts the appropriate separator, and decomposition and inspection know both systems' rules. This reference's examples ran on Linux, so the outputs contain a slash.

Loading the plugin

plugin "../plugins/print/PrintPlugin";
plugin "../plugins/path/PathPlugin";

A typical flow — building and decomposing a path

string $full[256];
string $dir[256];
$full = path.Join("data/input", "image.png");
$dir = path.DirName($full);
printf("%s | %s\n", $full, $dir);

What to know about every function (the basics)

  • Purely textual operations: the plugin does not touch the file system, and does not check whether the path points to an existing file/directory.

  • Join joins with the appropriate separator and does not double a redundant separator; if the relative part is absolute, it returns it unchanged.

  • DirName returns the directory part; if there is no directory component (just a file name), the “.” (current directory).

  • BaseName returns the last component, trimming the trailing separator(s).

  • IsAbsolute returns 1/0; Normalize resolves the “.” and “..” segments and collapses double separators.

  • An error (stopping the script) is caused only by a wrong argument count or type.

How to read the signatures

baseDir is a base directory, relativePath is a part to append to it, filePath/path is an arbitrary path. The type after the -> arrow is the return type. For example, path.Join(baseDir, relativePath) -> string takes two path parts and returns the joined path.

Joining

Safely joining two path parts with the appropriate separator.

path.Join

path.Join(baseDir, relativePath) -> string

Joins a base directory and a relative path with the system separator.

Parameters
Parameter Type Description
baseDir string The base directory (for empty or “.” it returns just the relative part).
relativePath string The part to append (if it is absolute, it is returned unchanged).
Return value

The joined path. It does not double a redundant separator.

Example
printf("%s\n", path.Join("a/b", "c.txt"));
printf("%s\n", path.Join("a/b/", "c.txt"));
printf("%s\n", path.Join("a", "/abs/x"));
Output after running
a/b/c.txt
a/b/c.txt
/abs/x
When to use

For safely building paths instead of manual string concatenation: it handles the separator correctly (does not omit or double it), and takes over an absolute relative part correctly too.

Decomposition

Extracting the directory or the file-name part from a path.

path.DirName

path.DirName(filePath) -> string

Extracts the path's directory part (the part before the last separator).

Parameters
Parameter Type Description
filePath string The path to decompose.
Return value

The directory part. If there is no directory component (just a file name), the “.” (current directory).

Example
printf("%s\n", path.DirName("/a/b/c.txt"));
printf("%s\n", path.DirName("c.txt"));
Output after running
/a/b
.
When to use

To get a file's directory — for example to write another file into the same folder, or to create the directory structure.

path.BaseName

path.BaseName(filePath) -> string

Extracts the path's last component (the file or directory name).

Parameters
Parameter Type Description
filePath string The path to decompose.
Return value

The last component (trimming the trailing separator(s)).

Example
printf("%s\n", path.BaseName("/a/b/c.txt"));
printf("%s\n", path.BaseName("/a/b/"));
Output after running
c.txt
b
When to use

To get the file name (or the innermost directory's name) — for example for display, logging, or further processing of the extension.

Inspection and normalization

Deciding whether a path is absolute and removing the redundant parts.

path.IsAbsolute

path.IsAbsolute(filePath) -> int

Tells whether the path is absolute (per the system's rules).

Parameters
Parameter Type Description
filePath string The path to inspect.
Return value

1 if the path is absolute; otherwise 0.

Example
printf("%d\n", path.IsAbsolute("/a/b"));
printf("%d\n", path.IsAbsolute("a/b"));
Output after running
1
0
When to use

To decide whether a path needs to be joined to a base directory (relative) or can be used on its own (absolute). On Windows it also recognizes the drive letter (C:\) and the network path.

path.Normalize

path.Normalize(path) -> string

Normalizes the path: resolves the “.” and “..” segments and collapses double separators.

Parameters
Parameter Type Description
path string The path to normalize.
Return value

The normalized path (the redundant parts removed).

Example
printf("%s\n", path.Normalize("a/./b/../c"));
printf("%s\n", path.Normalize("/a//b/"));
Output after running
a/c
/a/b
When to use

To clean up paths and make them comparable — for example to simplify user input or joined paths before displaying them or using them as keys.

Practical notes

What the path plugin is good for

  • Safely building file paths instead of manual string concatenation (Join).

  • Extracting a path's parts: the directory (DirName) and the file name (BaseName).

  • Distinguishing relative and absolute paths (IsAbsolute).

  • Cleaning up and simplifying paths by removing the redundant parts (Normalize).

Text only — no file system

The path plugin performs purely textual operations: it does not open the file, does not check its existence, and does not resolve symbolic links. If you also want to know whether the path points to an existing file, use fileio.Exists. The two plugins complement each other well: path builds/decomposes the path, and fileio performs the actual file operation.

Cross-platform behavior

The plugin uses the running system's separator (Linux: /, Windows: \), and the inspections (IsAbsolute) know both systems' rules. So the same script produces the appropriate path form on both platforms. This reference's outputs were produced on Linux.

Error handling

The path functions report only a wrong argument count or type as a runtime error (the script then stops). Otherwise they always give a meaningful result: even for empty or unusual input a well-defined answer (for example DirName returns “.” if there is no directory part). Since there is no file-system access, there is no I/O error either.

The stdio standard I/O plugin

Writing to standard output and error, reading lines, and flushing — complete function reference