S-Lang Run-Time Library Reference: Version 2.0.4: Functions that Parse Filenames

Next Previous Contents

## 16. Functions that Parse Filenames

## 16.1 path_basename

Synopsis

  Get the basename part of a filename

Usage

  `String_Type path_basename (String_Type filename)`

Description

  The `path_basename` function returns the basename associated with the `filename` parameter. The basename is the non-directory part of the filename, e.g., on unix `c` is the basename of `/a/b/c`.

See Also

  `path_dirname, path_extname, path_concat, path_is_absolute`

## 16.2 path_basename_sans_extname

Synopsis

  Get the basename part of a filename but without the extension

Usage

  `String_Type path_basename_sans_extname (String_Type path)`

Description

  The `path_basename_sans_extname` function returns the basename associated with the `filename` parameter, omitting the extension if present. The basename is the non-directory part of the filename, e.g., on unix `c` is the basename of `/a/b/c`.

See Also

  `path_dirname, path_basename, path_extname, path_concat, path_is_absolute`

## 16.3 path_concat

Synopsis

  Combine elements of a filename

Usage

  `String_Type path_concat (String_Type dir, String_Type basename)`

Description

  The `path_concat` function combines the arguments `dir` and `basename` to produce a filename. For example, on Unix if `dir` is `x/y` and `basename` is `z`, then the function will return `x/y/z`.

See Also

  `path_dirname, path_basename, path_extname, path_is_absolute`

## 16.4 path_dirname

Synopsis

  Get the directory name part of a filename

Usage

  `String_Type path_dirname (String_Type filename)`

Description

  The `path_dirname` function returns the directory name associated with a specified filename.

Notes

  On systems that include a drive specifier as part of the filename, the value returned by this function will also include the drive specifier.

See Also

  `path_basename, path_extname, path_concat, path_is_absolute`

## 16.5 path_extname

Synopsis

  Return the extension part of a filename

Usage

  `String_Type path_extname (String_Type filename)`

Description

  The `path_extname` function returns the extension portion of the specified filename. If an extension is present, this function will also include the dot as part of the extension, e.g., if `filename` is `"file.c"`, then this function will return `".c"`. If no extension is present, the function returns an empty string `""`.

Notes

  Under VMS, the file version number is not returned as part of the extension.

See Also

  `path_sans_extname, path_dirname, path_basename, path_concat, path_is_absolute`

## 16.6 path_get_delimiter

Synopsis

  Get the value of a search-path delimiter

Usage

  `Char_Type path_get_delimiter ()`

Description

  This function returns the value of the character used to delimit fields of a search-path.

See Also

  `set_slang_load_path, get_slang_load_path`

## 16.7 path_is_absolute

Synopsis

  Determine whether or not a filename is absolute

Usage

  `Int_Type path_is_absolute (String_Type filename)`

Description

  The `path_is_absolute` function will return non-zero is `filename` refers to an absolute filename, otherwise it returns zero.

See Also

  `path_dirname, path_basename, path_extname, path_concat`

## 16.8 path_sans_extname

Synopsis

  Strip the extension from a filename

Usage

  `String_Type path_sans_extname (String_Type filename)`

Description

  The `path_sans_extname` function removes the file name extension (including the dot) from the filename and returns the result.

See Also

  `path_basename_sans_extname, path_extname, path_basename, path_dirname, path_concat`

Next Previous Contents