ESO Recipe Execution Tool  3.13
Functions
EsoRex File Utility Functions

Functions

const char * er_fileutils_tilde_replace (const char *name)
 Replaces the leading tilde (~) in a name. More...
 
const char * er_fileutils_dot_replace (const char *name)
 Replaces the leading dot (.) in a name. More...
 
int fileutils_directory_exists (const char *directory_name)
 Checks whether the given directory actually exists. More...
 
int fileutils_file_exists (const char *file_name)
 Checks whether the given file actually exists. More...
 
char * fileutils_create_fqfname (char *dir_name, char *file_name)
 Creates a Fully Qualified File Name based on a directory name and a filename. More...
 
char * fileutils_fqfname_filename (const char *path)
 Extracts filename from a Fully Qualified File Name. More...
 
char * fileutils_fqfname_dirname (const char *path)
 Extracts directoryname from a Fully Qualified File Name. More...
 
int er_fileutils_file_is_fits (const char *name)
 Determine whether a given file is a FITS file. More...
 

Detailed Description

Utility functions for hadling files.

Function Documentation

const char* er_fileutils_dot_replace ( const char *  name)

Replaces the leading dot (.) in a name.

Parameters
nameThe 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
nameThe name of the fits
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
nameThe 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_nameDirectory
file_nameFile
Returns
A newly allocated string containing FQFN
int fileutils_directory_exists ( const char *  directory_name)

Checks whether the given directory actually exists.

Parameters
directory_nameDirectory
Returns
TRUE if directory exists, FALSE otherwise
int fileutils_file_exists ( const char *  file_name)

Checks whether the given file actually exists.

Parameters
file_nameFilename
Returns
1 if file exists, 0 otherwise
char* fileutils_fqfname_dirname ( const char *  path)

Extracts directoryname from a Fully Qualified File Name.

Parameters
pathFQFN
Returns
A newly allocated string containing directoryname
char* fileutils_fqfname_filename ( const char *  path)

Extracts filename from a Fully Qualified File Name.

Parameters
pathFQFN
Returns
A newly allocated string containing Filename