CLibs
Loading...
Searching...
No Matches
filenames.h File Reference
#include "attributes.h"
#include <stdbool.h>
#include <string.h>

Go to the source code of this file.

Macros

#define PATH_MAX   4096
 Maximum length of a file name.

Functions

LibraryDefined const char * get_file_name (const char *const full_path)
LibraryDefined const char * get_prog_name (void)
BeforeMain LibraryDefined bool set_prog_name (void)

Variables

LibraryDefined char ProgName [PATH_MAX+1] = "current-program"

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   4096

Maximum length of a file name.

Function Documentation

◆ get_file_name()

LibraryDefined const char * get_file_name ( const char *const full_path)

This function doesn't allocate any memory on the heap. Its return value is a pointer to a part of the full_path.

Example:

get_file_name( "/home/user/Hovno" ) // => "Hovno"
get_file_name( "Hovno" ) // => "Hovno"
get_file_name( "/a" ) // => "a"
get_file_name( "./a" ) // => "a"
get_file_name( "Directory/Subdir/" ) // => "Subdir/"
LibraryDefined const char * get_file_name(const char *const full_path)
Definition filenames.h:59
Parameters
full_pathFull path to file
Returns
pointer to the last part of ‹full_path›

◆ get_prog_name()

LibraryDefined const char * get_prog_name ( void )
inline

Fetches the name of the program currently being run.

Returns
Pointer to a static buffer

◆ set_prog_name()

BeforeMain LibraryDefined bool set_prog_name ( void )

Sets the static ProgName buffer to the current program's name if possible.

Returns
false if not successful

Variable Documentation

◆ ProgName

LibraryDefined char ProgName[PATH_MAX+1] = "current-program"

Static buffer for saving the program name.

If all efforts to set it to the actual name, it defaults to "current-program"