libu8
Functions
include/libu8/u8pathfns.h File Reference

These functions provide ways to manipulate file pathnames. More...

Functions

U8_EXPORT u8_string u8_getcwd (void)
 Gets the current working directory.
U8_EXPORT int u8_setcwd (u8_string dirname)
 Changes the current working directory.
U8_EXPORT char * u8_localpath (u8_string path)
 Returns an absolute local pathname from a utf-8 pathname.
U8_EXPORT u8_string u8_mkpath (u8_string dir, u8_string name)
 Makes a pathname by combining a directory and a name component.
U8_EXPORT u8_string u8_abspath (u8_string path, u8_string wd)
 Returns an absolute pathname given a current directory.
U8_EXPORT u8_string u8_dirname (u8_string path)
 Returns the directory component of a pathname.
U8_EXPORT u8_string u8_basename (u8_string path, u8_string suffix)
 Returns the non-directory non-suffix component of a pathname.
u8_string u8_realpath (u8_string path, u8_string wd)
 Returns an absolute pathname, resolving symbolic links.

Detailed Description

These functions provide ways to manipulate file pathnames.

They provide both utility functions and translation from unix-style UTF-8 pathnames to the local file system encoding and conventions. They do not provide access (in general) to file metadata or content.


Function Documentation

U8_EXPORT u8_string u8_abspath ( u8_string  path,
u8_string  wd 
)

Returns an absolute pathname given a current directory.

Parameters:
patha pathname
wda directory name
Returns:
a utf-8 string
U8_EXPORT u8_string u8_basename ( u8_string  path,
u8_string  suffix 
)

Returns the non-directory non-suffix component of a pathname.

Returns the non-directory non-suffix component of a pathname. If the suffix is provided, it is stripped from the end of the pathname.

Parameters:
patha utf-8 pathname
suffixa utf-8string
Returns:
a utf-8 pathname
U8_EXPORT u8_string u8_dirname ( u8_string  path)

Returns the directory component of a pathname.

Parameters:
patha utf-8 pathname
Returns:
a utf-8 directory pathname
U8_EXPORT u8_string u8_getcwd ( void  )

Gets the current working directory.

Converts its result from the local encoding to utf-8

Returns:
utf8_string
U8_EXPORT char* u8_localpath ( u8_string  path)

Returns an absolute local pathname from a utf-8 pathname.

This handles interpretation of relative pathnames and ~ prefixes as well as encoding conversion.

Parameters:
patha utf8 string
Returns:
a locally-encoded string
U8_EXPORT u8_string u8_mkpath ( u8_string  dir,
u8_string  name 
)

Makes a pathname by combining a directory and a name component.

Parameters:
dira utf-8 directory name
namea utf-8 filename
Returns:
a utf-8 string
u8_string u8_realpath ( u8_string  path,
u8_string  wd 
)

Returns an absolute pathname, resolving symbolic links.

Parameters:
patha pathname
wda directory name
Returns:
a utf-8 string
U8_EXPORT int u8_setcwd ( u8_string  dirname)

Changes the current working directory.

Converts its argument into the local encoding and calls chdir() to make it the default directory.

Parameters:
dirnamethe directory name in utf-8
Returns:
-1 on error, 0 otherwise