Utility functions for hadling files.
const char* er_fileutils_dot_replace |
( |
const char * |
name | ) |
|
Replaces the leading dot (.) in a name.
- Parameters
-
name | The input file name/path string |
- Returns
- A string with the replaced ".".
This function takes an input string. If the string begins with a single dot (.), then the function returns this string, but with the dot replaced by the current working directory (as an absolute path) using the $PWD environment variable. If not, then the string is returned unmodified.
OJO: this routine returns a pointer to a static string, if you need the returned filename later on, you must copy it to a string of PATHSET_MAX length otherwise the returned pointer may point later on to something very different :-(
int er_fileutils_file_is_fits |
( |
const char * |
name | ) |
|
Determine whether a given file is a FITS file.
- Parameters
-
- Returns
- 1 if the file is FITS, 0 if not, negative on error
const char* er_fileutils_tilde_replace |
( |
const char * |
name | ) |
|
Replaces the leading tilde (~) in a name.
- Parameters
-
name | The input file name/path string |
- Returns
- A string with the replaced tilde.
This function takes an input string. If the string begins with a tilde (~), then the function returns this string, but with the tilde replaced by the home directory of the current user (using the $HOME environment variable). If not, then the string is returned unmodified. This function also cleans up any multiple or trailing forward-slashes.
This function also performs the replacement of any environment variables.
OJO: this routine returns a pointer to a static string, if you need the returned filename later on, you must copy it to a string of PATHSET_MAX length otherwise the returned pointer may point later on to something very different :-(
char* fileutils_create_fqfname |
( |
char * |
dir_name, |
|
|
char * |
file_name |
|
) |
| |
Creates a Fully Qualified File Name based on a directory name and a filename.
- Parameters
-
dir_name | Directory |
file_name | File |
- Returns
- A newly allocated string containing FQFN
int fileutils_directory_exists |
( |
const char * |
directory_name | ) |
|
Checks whether the given directory actually exists.
- Parameters
-
- Returns
- TRUE if directory exists, FALSE otherwise
int fileutils_file_exists |
( |
const char * |
file_name | ) |
|
Checks whether the given file actually exists.
- Parameters
-
- Returns
- 1 if file exists, 0 otherwise
char* fileutils_fqfname_dirname |
( |
const char * |
path | ) |
|
Extracts directoryname from a Fully Qualified File Name.
- Parameters
-
- Returns
- A newly allocated string containing directoryname
char* fileutils_fqfname_filename |
( |
const char * |
path | ) |
|
Extracts filename from a Fully Qualified File Name.
- Parameters
-
- Returns
- A newly allocated string containing Filename