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

Go to the source code of this file.

Functions

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

Variables

string gFileCommentLine
 ! String indicating a line comment in a data file
 
string gFileSpaces
 ! String indicating all space characters
 

Detailed Description

Include 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().