GrafX2 2.9.3227
The ultimate 256-color painting program
File path and name

Functions used to manipulate files path and names. More...

Macros

#define PATH_SEPARATOR   "/"
 default path separator character More...
 

Functions

char * Filepath_append_to_dir (const char *dir, const char *filename)
 Construct full file path. More...
 
char * Extract_filename (const char *source)
 Extracts the filename part from a full file name. More...
 
char * Extract_path (const char *source)
 Extracts the directory from a full file name. More...
 
char * Find_last_separator (const char *str)
 Finds the rightmost path separator in a full filename. Used to separate directory from file. More...
 
wordFind_last_separator_unicode (const word *str)
 Finds the rightmost path separator in a full filename in unicode. Used to separate directory from file. More...
 
int Position_last_dot (const char *fname)
 finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found More...
 
int Position_last_dot_unicode (const word *fname)
 finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found More...
 
wordGet_Unicode_Filename (word *filename_unicode, const char *filename, const char *directory)
 Convert a file name to unicode characters. More...
 
void Append_path (char *path, const char *filename, char *reverse_path)
 Appends a file or directory name to an existing directory name. More...
 

Detailed Description

Functions used to manipulate files path and names.

Macro Definition Documentation

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   "/"

default path separator character

Function Documentation

◆ Filepath_append_to_dir()

◆ Extract_filename()

char * Extract_filename ( const char *  source)

Extracts the filename part from a full file name.

References Find_last_separator().

Referenced by Button_Load_or_Save(), Load_ClipBoard_Image(), and Test_File_exists().

◆ Extract_path()

char * Extract_path ( const char *  source)

Extracts the directory from a full file name.

References Find_last_separator(), GFX2_ERROR, GFX2_Log(), NULL, PATH_SEPARATOR, and Realpath().

Referenced by Get_program_directory(), and Load_ClipBoard_Image().

◆ Find_last_separator()

char * Find_last_separator ( const char *  str)

Finds the rightmost path separator in a full filename. Used to separate directory from file.

References NULL, and PATH_SEPARATOR.

Referenced by Analyze_command_line(), Append_path(), Backup_existing_file(), Button_Load_or_Save(), Extract_filename(), Extract_path(), and Main_handler().

◆ Find_last_separator_unicode()

word * Find_last_separator_unicode ( const word str)

Finds the rightmost path separator in a full filename in unicode. Used to separate directory from file.

References NULL, and PATH_SEPARATOR.

Referenced by Main_handler().

◆ Position_last_dot()

int Position_last_dot ( const char *  fname)

finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found

Referenced by Backup_existing_file(), Button_Load_or_Save(), Format_filename(), and Read_dir_callback().

◆ Position_last_dot_unicode()

int Position_last_dot_unicode ( const word fname)

finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found

Referenced by Button_Load_or_Save(), Format_filename_unicode(), and Read_dir_callback().

◆ Get_Unicode_Filename()

word * Get_Unicode_Filename ( word filename_unicode,
const char *  filename,
const char *  directory 
)

Convert a file name to unicode characters.

If the parametter is null, the buffer is malloc'ed

Parameters
filename_unicodethe output buffer of MAX_PATH_CHARACTERS wide characters
filenamethe input file name
directorythe input file directory
Returns
NULL if no conversion has taken place.
filename_unicode if the unicode filename has been retrieved

References GFX2_ERROR, GFX2_Log(), GFX2_malloc, MAX_PATH_CHARACTERS, and NULL.

Referenced by Button_Load_or_Save(), and Init_program().

◆ Append_path()

void Append_path ( char *  path,
const char *  filename,
char *  reverse_path 
)

Appends a file or directory name to an existing directory name.

As a special case, when the new item is equal to PARENT_DIR, this will remove the rightmost directory name. reverse_path is optional, if it's non-null, the function will write there :

  • if filename is ".." : The name of eliminated directory/file
  • else: ".."

References Find_last_separator(), PARENT_DIR, and PATH_SEPARATOR.