gmerlin
|
Functions for files and directories. More...
Functions | |
char * | bg_fix_path (char *path) |
Append a trailing slash to a path name. More... | |
int | bg_ensure_directory (const char *dir) |
Ensure that a directory exists. More... | |
char * | bg_search_file_read (const char *directory, const char *file) |
Search for a file for reading. More... | |
char * | bg_search_file_write (const char *directory, const char *file) |
Search for a file for writing. More... | |
int | bg_search_file_exec (const char *file, char **path) |
Search for an executable. More... | |
char * | bg_find_url_launcher () |
Find an URL launcher. More... | |
void | bg_display_html_help (const char *path) |
Display html help. More... | |
char * | bg_create_unique_filename (char *format) |
Create a unique filename. More... | |
char * | bg_canonical_filename (const char *name) |
Get the canonical filename. More... | |
char * | bg_filename_ensure_extension (const char *filename, const char *ext) |
Ensure a file extension. More... | |
Functions for files and directories.
char* bg_fix_path | ( | char * | path | ) |
Append a trailing slash to a path name.
path | Old path (will eventually be freed). |
int bg_ensure_directory | ( | const char * | dir | ) |
Ensure that a directory exists.
dir | Directory |
Non-existing directories will be created if possible
char* bg_search_file_read | ( | const char * | directory, |
const char * | file | ||
) |
Search for a file for reading.
directory | Directory |
file | Filename |
This function first seeks in the system gmerlin data directory (e.g. /usr/local/share/gmerlin), then in $HOME/.gmerlin for the specified file, which must be readable. The directory can also contain subdirectories e.g. "player/tree".
char* bg_search_file_write | ( | const char * | directory, |
const char * | file | ||
) |
Search for a file for writing.
directory | Directory |
file | Filename |
This function first seeks in the in $HOME/.gmerlin for the specified file, which must be writable. If the file doesn't exist, an empty file is created. If the directory doesn't exist, it's created as well. The directory can also contain subdirectories e.g. "player/tree".
int bg_search_file_exec | ( | const char * | file, |
char ** | path | ||
) |
Search for an executable.
file | Name of the file (without dirtectory) |
path | If non NULL, the complete path to the exectuable will be returned |
If path is non NULL, it will contain the path to the executable, which must be freed after
char* bg_find_url_launcher | ( | ) |
Find an URL launcher.
This returnes the path of a webbrowser. Under gnome, it will be the your default webbrowser, under other systems, this function will try a list of known webbrowsers.
void bg_display_html_help | ( | const char * | path | ) |
Display html help.
path | Path |
Launch a webbrowser and display a html file. Path is something lile "userguide/Player.html"
char* bg_create_unique_filename | ( | char * | format | ) |
Create a unique filename.
format | Printf like format. Must contain "%08x" as the only placeholder. |
Create a unique filename, and create an empty file of this name.
char* bg_canonical_filename | ( | const char * | name | ) |
Get the canonical filename.
name | Filename |
On Glibc systems, this calls canonicalize_file_name(3)
char* bg_filename_ensure_extension | ( | const char * | filename, |
const char * | ext | ||
) |
Ensure a file extension.
filename | Filename (with or without extension) |
ext | Extension to look for |
This function checks case insensitively if filename ends with the extension. If yes, it returns a copy of the filename. If not, it returns a copy with the extension appended. The extention must not start with the dot.