MLIB
Loading...
Searching...
No Matches
basename.h File Reference

Definitions for Unix-like basename() and dirname() functions. More...

Go to the source code of this file.

Functions

const char * mlib::dirname (const char *filename)
 Return a pointer to pathname of the file deleting any trailing '\' character.
 
const char * mlib::basename (const char *filename)
 Return a pointer to the filename without any path component.
 

Detailed Description

Definitions for Unix-like basename() and dirname() functions.

(c) Mircea Neacsu 2017

Function Documentation

◆ basename()

const char * mlib::basename ( const char *  filename)

Return a pointer to the filename without any path component.

Parameters
filenamepointer to filename with optional path
Returns
pointer to filename without path

Forward slashes ( / ), backslashes ( \ ), or both may be used.

If filename is a null pointer or points to an empty string, basename() returns a pointer to the string ".".

The function returns a pointer to a static storage that will be overwritten by a subsequent call to basename().

The function can be used with UTF-8 encoded filenames.

◆ dirname()

const char * mlib::dirname ( const char *  filename)

Return a pointer to pathname of the file deleting any trailing '\' character.

Parameters
filenamepointer to filename
Returns
pointer to pathname

Forward slashes ( / ), backslashes ( \ ), or both may be used. If the filename does not contain a '\', then dirname() returns a pointer to the string ".". If filename is a null pointer or points to an empty string, dirname() returns a pointer to the string "."

The function returns a pointer to a static storage that will be overwritten by a subsequent call to dirname().

The function can be used with UTF-8 encoded filenames.