From 8cb7089b2eb09d40d9497cea40d088d94676a8c6 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Fri, 23 Jan 2026 00:50:18 +0000 Subject: More docs, check 'docs/std'. --- docs/std/path.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 docs/std/path.md (limited to 'docs/std/path.md') diff --git a/docs/std/path.md b/docs/std/path.md new file mode 100644 index 0000000..0be30fd --- /dev/null +++ b/docs/std/path.md @@ -0,0 +1,58 @@ +# Standard Library: Path (`std/path.zc`) + +`Path` provides cross-platform file path manipulation utilities. It wraps a `String` and handles separators (slash vs backslash) intelligently, though currently biased towards Unix defaults pending full Windows support integration. + +## Usage + +```zc +import "std/path.zc" + +fn main() { + var p = Path::new("/home/user"); + var full_path = p.join("docs/file.txt"); + + println "Full path: {full_path.c_str()}"; + + if (full_path.extension().is_some()) { + println "Extension: {full_path.extension().unwrap()}"; + } +} +``` + +## Structure + +```zc +struct Path { + str: String; +} +``` + +## Methods + +### Construction + +| Method | Signature | Description | +| :--- | :--- | :--- | +| **new** | `Path::new(s: char*) -> Path` | Creates a new Path from a C string. | +| **from_string** | `Path::from_string(s: String) -> Path` | Creates a Path taking ownership of a String. | + +### Manipulation + +| Method | Signature | Description | +| :--- | :--- | :--- | +| **join** | `join(self, other: char*) -> Path` | Joins the current path with `other` using the correct separator. Returns a new Path. | +| **clone** | `clone(self) -> Path` | Creates a deep copy of the Path. | + +### Parsing + +| Method | Signature | Description | +| :--- | :--- | :--- | +| **extension** | `extension(self) -> Option` | Returns the file extension (without the dot), or `None` if no extension. | +| **file_name** | `file_name(self) -> Option` | Returns the last component of the path. | +| **parent** | `parent(self) -> Option` | Returns the path without its final component. | + +### Access + +| Method | Signature | Description | +| :--- | :--- | :--- | +| **c_str** | `c_str(self) -> char*` | Returns a pointer to the underlying C string. | -- cgit v1.2.3