Filesystem support
[Utilities]

Functions for files and directories. More...

Functions

char * bg_fix_path (char *path)
 Append a trailing slash to a path name.
int bg_ensure_directory (const char *dir)
 Ensure that a directory exists.
char * bg_search_file_read (const char *directory, const char *file)
 Search for a file for reading.
char * bg_search_file_write (const char *directory, const char *file)
 Search for a file for writing.
int bg_search_file_exec (const char *file, char **path)
 Search for an executable.
char * bg_find_url_launcher ()
 Find an URL launcher.
void bg_display_html_help (const char *path)
 Display html help.
char * bg_create_unique_filename (char *format)
 Create a unique filename.
char * bg_filename_ensure_extension (const char *filename, const char *ext)
 Ensure a file extension.

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
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
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)
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:
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.

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_filename_ensure_extension ( const char *  filename,
const char *  ext 
)

Ensure a file extension.

Parameters:
filename Filename (with or without extension)
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.

Generated on Wed Jul 21 17:05:54 2010 for gmerlin by  doxygen 1.6.3