Filesystem support
[Utilities]
Functions for files and directories.
More...
Detailed Description
Functions for files and directories.
Function Documentation
char* bg_fix_path |
( |
char * |
path |
) |
|
Append a trailing slash to a path name.
- Parameters:
-
| path | Old path (will eventually be freed). - Returns:
- The path, which is garantueed to end with a '/'
|
int bg_ensure_directory |
( |
const char * |
dir |
) |
|
Ensure that a directory exists.
- Parameters:
-
| dir | Directory - Returns:
- 1 if the directory exists after the function call, 0 else
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.
- Parameters:
-
| directory | Directory - Parameters:
-
| file | Filename - Returns:
- A filename or NULL
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.
- Parameters:
-
| directory | Directory - Parameters:
-
| file | Filename - Returns:
- A filename or NULL
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.
- Parameters:
-
| file | Name of the file (without dirtectory) - Parameters:
-
| path | If non NULL, the complete path to the exectuable will be returned - Returns:
- 1 if executeable is found anywhere in $PATH:/opt/gmerlin/bin, 0 else.
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.
- Returns:
- A newly allocated string, which must be freed
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.
- Parameters:
-
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.
- Parameters:
-
| format | Printf like format. Must contain "%08x" as the only placeholder. - Returns:
- A newly allocated string
Create a unique filename, and create an empty file of this name. |
char* bg_canonical_filename |
( |
const char * |
name |
) |
|
Get the canonical filename.
- Parameters:
-
| name | Filename - Returns:
- A newly allocated 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.
- Parameters:
-
| filename | Filename (with or without extension) - Parameters:
-
| extension | Extension to look for - Returns:
- A newly allocated filename
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. |
|