# std.path

Path manipulation utilities for working with file paths.

```tea
use path from "std.path"
```

Examples may be fragments requiring the module import or additional setup.

## std.path.asset

```tea
pub def asset(name: String) -> String
```

Resolve an asset independently of the working directory. Uses TEA_ASSET_ROOT in development, otherwise assets/ beside the executable. This is a path convenience, not a sandbox for untrusted filenames.

## std.path.join

```tea
pub def join(parts: List[String]) -> String
```

Join path components into a single path.

```tea
var path = path.join(["usr", "local", "bin"])  # => "usr/local/bin"
```

## std.path.split

```tea
pub def split(file_path: String) -> List[String]
```

Split a path into its components.

```tea
var parts = path.split("/usr/local/bin")  # => ["usr", "local", "bin"]
var parts = path.split("usr/local/")  # => ["usr", "local"]
```

## std.path.dirname

```tea
pub def dirname(file_path: String) -> String
```

Get the directory part of a path.

```tea
var dir = path.dirname("/usr/local/bin/tea")  # => "/usr/local/bin"
var dir = path.dirname("/usr/local/")  # => "/usr/local"
var dir = path.dirname("file.txt")  # => ""
var dir = path.dirname("/")  # => "/"
```

## std.path.basename

```tea
pub def basename(file_path: String) -> String
```

Get the filename part of a path.

```tea
var name = path.basename("/usr/local/bin/tea")  # => "tea"
var name = path.basename("/usr/local/")  # => "local"
var name = path.basename("file.txt")  # => "file.txt"
var name = path.basename("/")  # => ""
```

## std.path.extension

```tea
pub def extension(file_path: String) -> String
```

Get the extension of a path.

```tea
var ext = path.extension("file.tea")  # => "tea"
var ext = path.extension("file.tar.gz")  # => "gz"
var ext = path.extension(".env")  # => ""
var ext = path.extension("file")  # => ""
```

## std.path.normalize

```tea
pub def normalize(file_path: String) -> String
```

Normalize a path by resolving redundant separators and dot segments.

```tea
use path from "std.path"

@println(path.normalize("src/./old/../main.tea")) # src/main.tea on Unix
```

## std.path.absolute

```tea
pub def absolute(file_path: String) -> String
```

Resolve a path to an absolute path using the current working directory.

## std.path.absolute_from

```tea
pub def absolute_from(file_path: String, base_path: String) -> String
```

Resolve a path to an absolute path using an explicit base directory.

```tea
use path from "std.path"

const root = path.absolute(".")
@println(path.absolute_from("src/main.tea", root)) # Absolute path under root
```

## std.path.relative

```tea
pub def relative(target_path: String, base_path: String) -> String
```

Compute the relative path from a base location to a target.

```tea
use path from "std.path"

const root = path.absolute(".")
const target = path.join([root, "src", "main.tea"])
@println(path.relative(target, root)) # src/main.tea on Unix
```

## std.path.is_absolute

```tea
pub def is_absolute(file_path: String) -> Bool
```

Return true when a path is absolute.

## std.path.separator

```tea
pub def separator() -> String
```

Return the platform-specific path separator.

## std.path.parent

```tea
pub def parent(file_path: String) -> String
```

Alias for dirname().

## std.path.stem

```tea
pub def stem(file_path: String) -> String
```

Return the file name without its final extension.

```tea
use path from "std.path"

@println(path.stem("reports/archive.tar.gz")) # archive.tar
```
