GCpp general purpose C++ library  version 1.0
GFileFunctions.cpp File Reference
#include "GFileFunctions.hh"
#include "GString.hh"
#include "GStringList.hh"

Functions

string GFileReadLine (FILE *fptr, int &error, const bool skip_empty, const u_int maxlen)
 
int GGetFileList (GStringList &flist, const string &dir, const string &pattern)
 
int GGetFileList (GStringList &flist, const string &pattern)
 

Variables

string gFileCommentLine = "#"
 ! String indicating a line comment in a data file
 
string gFileSpaces = " \n\t\r"
 ! String indicating all space characters
 

Detailed Description

Source file for various functions related to files

Function Documentation

string GFileReadLine ( FILE *  fptr,
int &  error,
const bool  skip_empty,
const u_int  maxlen 
)

Read a line from a file, taking care of spaces and comments:

  • if a line contains only spaces (see gFileSpaces), the line is ignored if the argument skip_empty is true (default value), and the next line is read.
  • if a comment marker is found (see gFileCommentLine), the line is truncated at the marker position. The function returns an empty string in case of error (error value > 0) or if the end of the file is reached (error value = -1).
    Parameters
    fptrfile pointer
    errorerror code
    skip_emptyindicate the empty lines should be skipped
    maxlenmaximum string length

References gFileCommentLine, and gFileSpaces.

int GGetFileList ( GStringList flist,
const string &  dir,
const string &  pattern 
)

Get a list of files matching the pattern in the directory.

Parameters
flistlist of file names (output)
dirdirectory name
patternfile pattern to match

References GListT< T >::Append(), GGetFileList(), and GLogWarning().

Referenced by GStringList::GetFileList(), and GGetFileList().

int GGetFileList ( GStringList flist,
const string &  pattern 
)

Get a list of files matching the pattern.

Parameters
flistlist of file names (output)
patternfile pattern to match

References GListT< T >::Append(), and GLogWarning().