Zen API
 All Classes Files Functions Variables Typedefs Macros Groups Pages
kPath Class Reference

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
segment1First path segment.
segment2Second path segment.
pathReceives the combined path segments.
capacityMaximum 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
pathFile or directory path.
directoryReceives the parent directory.
capacityMaximum 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
pathFile path.
extensionReceives the file extension portion of the path.
capacityMaximum 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
pathFile path.
fileNameReceives the file name portion of the path.
capacityMaximum 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
chCharacter 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
pathInput path, in native or mixed form.
normalizedReceives transformed path, in normal form.
capacityMaximum 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
pathAAbsolute reference path.
bRelativeToAPath b, expressed as relative to path A.
pathBReceives path b, expressed as an absolute path.
capacityMaximum 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
pathInput path, in normal or mixed form.
nativeReceives transformed path, in native form.
capacityMaximum 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
pathAAbsolute reference path.
pathBAbsolute path to be re-expressed as relative to path A.
bRelativeToAReceives path b, expressed as relative to path A.
capacityMaximum number of characters (including null terminator) for the relative path.
Returns
Operation status.

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