# path

> A Node.js-compatible implementation of the core `path` module

- Source: https://titaniumsdk.com/docs/sdk/12.6.3/path
- Titanium SDK version: 12.6.3
- Kind: pseudo
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 8.1.0

Titanium provides a number of shims and ports of core Node.js module functionality.

This module is intended to provide a Node-compatible port of the `path` core module.

More details on the Node.js API can be found in their [path module documentation](https://nodejs.org/api/path.html)

## Properties

### delimiter

- Type: String
- Platforms: Android, iPhone, iPad, macOS

Provides the platform-specific path delimiter:

`;` for Windows
`:` for POSIX

### posix

- Type: path
- Platforms: Android, iPhone, iPad, macOS

The `path.posix` property provides access to POSIX specific implementations of the `path` methods.

### sep

- Type: String
- Platforms: Android, iPhone, iPad, macOS

Provides the platform-specific path segment separator:

- `\` on Windows
- `/` on POSIX

### win32

- Type: path
- Platforms: Android, iPhone, iPad, macOS

The `path.win32` property provides access to Windows-specific implementations of the `path` methods.

## Methods

### basename

- Platforms: Android, iPhone, iPad, macOS

The `path.basename()` method returns the last portion of a `path`, similar to the Unix `basename` command. Trailing directory separators are ignored, see [path.sep](https://titaniumsdk.com/docs/sdk/path.md#sep).

Parameters:

- `path` (String): The file path.
- `ext` (String, optional): An optional file extension

Returns: String

### dirname

- Platforms: Android, iPhone, iPad, macOS

The `path.dirname()` method returns the directory name of a `path`, similar to the Unix `dirname` command. Trailing directory separators are ignored, see [path.sep](https://titaniumsdk.com/docs/sdk/path.md#sep).

Parameters:

- `path` (String): The file path.

Returns: String

### extname

- Platforms: Android, iPhone, iPad, macOS

The `path.extname()` method returns the extension of the `path`, from the last occurrence of the `.` (period) character to end of string in the last portion of the path. If there is no `.` in the last portion of the path, or if there are no `.` characters other than the first character of the `basename` of `path` (see [path.basename](https://titaniumsdk.com/docs/sdk/path.md#basename)`()`) , an empty string is returned.

Parameters:

- `path` (String): The file path.

Returns: String

### format

- Platforms: Android, iPhone, iPad, macOS

The `path.format()` method returns a `path` string from an object. This is the opposite of [path.parse](https://titaniumsdk.com/docs/sdk/path.md#parse)`()`.

When providing properties to the `pathObject` remember that there are combinations where one property has priority over another:

`pathObject.root` is ignored if `pathObject.dir` is provided
`pathObject.ext` and `pathObject.name` are ignored if `pathObject.base` exists

Parameters:

- `pathObject` (PathObject): The file path.

Returns: String

### isAbsolute

- Platforms: Android, iPhone, iPad, macOS

The `path.isAbsolute()` method determines if `path` is an absolute path.

If the given `path` is a zero-length string, `false` will be returned.

Parameters:

- `path` (String): The file path.

Returns: Boolean

### join

- Platforms: Android, iPhone, iPad, macOS

The `path.join()` method joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

Zero-length `path` segments are ignored. If the joined path string is a zero-length string then `'.'` will be returned, representing the current working directory.

Parameters:

- `paths` (String, optional, repeatable): A sequence of path segments

Returns: String

### normalize

- Platforms: Android, iPhone, iPad, macOS

The `path.normalize()` method normalizes the given `path`, resolving `'..'` and `'.'` segments.

When multiple, sequential path segment separation characters are found (e.g. `/` on POSIX and either `\` or `/` on Windows), they are replaced by a single instance of the platform-specific path segment separator (`/` on POSIX and `\` on Windows). Trailing separators are preserved.

If the `path` is a zero-length string, `'.'` is returned, representing the current working directory.

Parameters:

- `path` (String): The file path.

Returns: String

### parse

- Platforms: Android, iPhone, iPad, macOS

The `path.parse()` method returns an object whose properties represent significant elements of the `path`. Trailing directory separators are ignored, see [path.sep](https://titaniumsdk.com/docs/sdk/path.md#sep).

Parameters:

- `path` (String): The file path.

Returns: PathObject

### relative

- Platforms: Android, iPhone, iPad, macOS

The `path.relative()` method returns the relative path from from to to based on the current working directory. If `from` and `to` each resolve to the same path (after calling `path.resolve()` on each), a zero-length string is returned.

If a zero-length string is passed as `from` or `to`, the current working directory will be used instead of the zero-length strings.

Parameters:

- `from` (String): The source file path.
- `to` (String): The destination file path.

Returns: String

### resolve

- Platforms: Android, iPhone, iPad, macOS

The `path.resolve()` method resolves a sequence of paths or path segments into an absolute path.

The given sequence of paths is processed from right to left, with each subsequent `path` prepended until an absolute path is constructed. For instance, given the sequence of path segments: `/foo`, `/bar`, `baz`, calling `path.resolve('/foo', '/bar', 'baz')` would return `/bar/baz` because `'baz'` is not an absolute path but `'/bar' + '/' + 'baz'` is.

If, after processing all given `path` segments, an absolute path has not yet been generated, the current working directory is used.

The resulting path is normalized and trailing slashes are removed unless the path is resolved to the root directory.

Zero-length `path` segments are ignored.

If no `path` segments are passed, `path.resolve()` will return the absolute path of the current working directory.

Parameters:

- `paths` (String, optional, repeatable): A sequence of paths or path segments

Returns: String

### toNamespacedPath

- Platforms: Android, iPhone, iPad, macOS

On Windows systems only, returns an equivalent namespace-prefixed path for the given `path`. If `path` is not a string, `path` will be returned without modifications.

This method is meaningful only on Windows systems. On POSIX systems, the method is non-operational and always returns `path` without modifications.

Parameters:

- `path` (String): The file path.

Returns: String

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

