C Standard Library Extensions  1.2
Functions
File Utilities

Functions

cxlong cx_path_max (const cxchar *path)
 Get the maximum length of a path relative to the given directory. More...
 
cxchar * cx_path_alloc (const char *path)
 Allocate a buffer suitable for storing a relative pathname staring at a given directory. More...
 

Detailed Description

The module provides a collection of useful file and file path related utility functions.

Synopsis:
#include <cxfileutils.h>

Function Documentation

cxchar* cx_path_alloc ( const char *  path)

Allocate a buffer suitable for storing a relative pathname staring at a given directory.

Parameters
pathDirectory name the relative path should start from.
Returns
Allocated buffer of appropriate size, or NULL in case of an error.

The function determines the maximum possible length of a relative path name when path is the current working directory. A buffer with the appropriate length for the relative pathname including the trailing zero. The argument path must be the name of an existing, or the function fails. The allocated buffer can be destroyed by calling cx_free().

IF the string "/" is used for path the returned buffer will have the maximum length possible for an absolute path supported by the system (but see the note for cx_path_max() for pitfalls).

References cx_calloc(), and cx_path_max().

cxlong cx_path_max ( const cxchar *  path)

Get the maximum length of a path relative to the given directory.

Parameters
pathDirectory name.
Returns
Maximum path length.

The function returns the maximum length a relative path when path is the current working directory. To get the maximum possible length of an absolute path pass "/" for path, but see the note below. The size is determined through the pathconf() function, or if this is not available the maximum length is simply set to the ad hoc length of 4095 characters.

Note
The maximum length of a pathname depends on the underlying filesystem. This means that the method to determine the maximum possible length of an absolute pathname might be incorrect if the root directory and the actual location of the file under consideration are located on different filesystems.

Referenced by cx_path_alloc().