Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
Public Member Functions
kPath Class Reference
kApi/Io

## Description

Collection of path manipulation functions.

Most of the functions in this class expect paths to be in normal form (canonical separator character, no trailing slashes). The kPath_Normalize function can be used to normalize paths prior to calling other kPath functions.

The kPath_ToNative function can be used to transform a path in normal form to to a form suitable for the underlying system (native separator).

## Public Member Functions
kStatus | kPath_Combine (const kChar *segment1, const kChar *segment2, kChar *path, kSize capacity)
| Combines two path segments using the normalized path separator character. More...
kStatus | kPath_Directory (const kChar *path, kChar *directory, kSize capacity)
| Returns the parent directory for a given file or directory path. More...
kStatus | kPath_Extension (const kChar *path, kChar *extension, kSize capacity)
| Given a file path, returns the portion of the path containing the file extension. More...
kStatus | kPath_FileName (const kChar *path, kChar *fileName, kSize capacity)
| Given a file path, returns the portion of the path containing the file name. More...
kBool | kPath_IsSeparator (kChar ch)
| Determines if the given character is equal to the normalized path separator. More...
kStatus | kPath_Normalize (const kChar *path, kChar *normalized, kSize capacity)
| Transforms all path separators to normal form and removes trailing slashes. More...
kChar | kPath_Separator ()
| Returns the normalized path separator character. More...
kStatus | kPath_ToAbsolute (const kChar *pathA, const kChar *bRelativeToA, kChar *pathB, kSize capacity)
| Finds the absolute path expressed by the combination of an absolute path and a relative path. More...
kStatus | kPath_ToNative (const kChar *path, kChar *native, kSize capacity)
| Transforms all path separators to native form. More...
kStatus | kPath_ToRelative (const kChar *pathA, const kChar *pathB, kChar *bRelativeToA, kSize capacity)
| Expresses an absolute path in relative form, in relation to a reference path. More...

## Member Function Documentation

kStatus kPath_Combine | ( | const kChar * | segment1,
|  | const kChar * | segment2,
|  | kChar * | path,
|  | kSize | capacity
| ) |  |

Combines two path segments using the normalized path separator character.

The path (output) argument can refer to the same memory address as either of the segment (input) arguments.

Parameters

  segment1 | First path segment.
  segment2 | Second path segment.
  path | Receives the combined path segments.
  capacity | Maximum number of characters (including null terminator).

Returns
  Operation status.

kStatus kPath_Directory | ( | const kChar * | path,
|  | kChar * | directory,
|  | kSize | capacity
| ) |  |

Returns the parent directory for a given file or directory path.

The directory (output) argument can refer to the same memory address as the path (input) argument.

If the path contains embedded relative path components, this function will not attempt to evaluate the meaning of those components.

Parameters

  path | File or directory path.
  directory | Receives the parent directory.
  capacity | Maximum number of characters (including null terminator).

Returns
  Operation status.

kStatus kPath_Extension | ( | const kChar * | path,
|  | kChar * | extension,
|  | kSize | capacity
| ) |  |

Given a file path, returns the portion of the path containing the file extension.

The extension (output) argument can refer to the same memory address as the path (input) argument.

Parameters

  path | File path.
  extension | Receives the file extension portion of the path.
  capacity | Maximum number of characters (including null terminator).

Returns
  Operation status.

kStatus kPath_FileName | ( | const kChar * | path,
|  | kChar * | fileName,
|  | kSize | capacity
| ) |  |

Given a file path, returns the portion of the path containing the file name.

The fileName (output) argument can refer to the same memory address as the path (input) argument.

Parameters

  path | File path.
  fileName | Receives the file name portion of the path.
  capacity | Maximum number of characters (including null terminator).

Returns
  Operation status.

kBool kPath_IsSeparator | ( | kChar | ch | ) |

Determines if the given character is equal to the normalized path separator.

Parameters

  ch | Character to examine.

Returns
  kTRUE if the character is the normalized path separator.

kStatus kPath_Normalize | ( | const kChar * | path,
|  | kChar * | normalized,
|  | kSize | capacity
| ) |  |

Transforms all path separators to normal form and removes trailing slashes.

The normalized (output) argument can refer to the same memory address as the path (input) argument.

Parameters

  path | Input path, in native or mixed form.
  normalized | Receives transformed path, in normal form.
  capacity | Maximum number of characters (including null terminator) for normalized path.

Returns
  Operation status.

kChar kPath_Separator | ( |  | ) |

Returns the normalized path separator character.

Returns
  Path separator character.

kStatus kPath_ToAbsolute | ( | const kChar * | pathA,
|  | const kChar * | bRelativeToA,
|  | kChar * | pathB,
|  | kSize | capacity
| ) |  |

Finds the absolute path expressed by the combination of an absolute path and a relative path.

If bRelativeToA is already expressed in absolute form, then pathB will receive an absolute path equal to bRelativeToA.

The pathB (output) argument can refer to the same memory address as either the pathA or bRelativeToA (input) arguments.

Parameters

  pathA | Absolute reference path.
  bRelativeToA | Path b, expressed as relative to path A.
  pathB | Receives path b, expressed as an absolute path.
  capacity | Maximum number of characters (including null terminator) for path b.

Returns
  Operation status.

kStatus kPath_ToNative | ( | const kChar * | path,
|  | kChar * | native,
|  | kSize | capacity
| ) |  |

Transforms all path separators to native form.

The native (output) argument can refer to the same memory address as the path (input) argument.

Parameters

  path | Input path, in normal or mixed form.
  native | Receives transformed path, in native form.
  capacity | Maximum number of characters (including null terminator) for native path.

Returns
  Operation status.

kStatus kPath_ToRelative | ( | const kChar * | pathA,
|  | const kChar * | pathB,
|  | kChar * | bRelativeToA,
|  | kSize | capacity
| ) |  |

Expresses an absolute path in relative form, in relation to a reference path.

If pathA and pathB are rooted in different volumes, then bRelativeToA will receive an absolute path equal to pathB.

The bRelativeToA (output) argument can refer to the same memory address as either the pathA or pathB (input) arguments.

Parameters

  pathA | Absolute reference path.
  pathB | Absolute path to be re-expressed as relative to path A.
  bRelativeToA | Receives path b, expressed as relative to path A.
  capacity | Maximum number of characters (including null terminator) for the relative path.

Returns
  Operation status.

The documentation for this class was generated from the following file:

- Io/kPath.h