Defines | Functions | Variables

src/core/utilities.c File Reference

Defines

#define COPY_STR   "cp %s %s"

Functions

bool endsWith (char *string, char *ending)
char * strip (char *aString)
int longestName (char *filenames[], int nFiles)
bool lowerStrNCmp (const char *str1, const char *str2, int n)
void stringTokenizer (char *line)
char * nextToken ()
char * constructFileName (char *baseDir, const char *fileName)
char * constructFileNameOld (char *basedir, char *filename)
char * td_malloc (size_t size)
void td_free (void *mem, size_t size)
long getMemoryReport ()
DIR * exists (const char *name)
bool isEmpty (DIR *pd)
bool isWritable (char *pathname)
bool isReadable (char *pathname)
void copyFiles (const char *source, const char *dest)
DIR * getDirectory (char *dirName)
DIR * getDirectoryR (char *dirNameOrig)
char * getParent (char *path)
void getParentNChild (char *path, char **parentPtr, char **childPtr)
char * getNextEmptyDirectory (char *baseDir)

Variables

int MAX_DIRECTORY_VERSION = 9999
static int parserIdx = -1
static char * parserLine = NULL
static int parserLineLength = -1
static long MemoryInUse = 0

Define Documentation

#define COPY_STR   "cp %s %s"

Function Documentation

char* constructFileName ( char *  baseDir,
const char *  fileName 
)
char* constructFileNameOld ( char *  basedir,
char *  filename 
)
void copyFiles ( const char *  source,
const char *  dest 
)

Copy file from source to destination. This function make a system call to perform the copy.

Parameters:
[in] source Character string containing path to source file.
[in] dest Character string containing path to destination.
bool endsWith ( char *  string,
char *  ending 
)
DIR* exists ( const char *  name  ) 
DIR* getDirectory ( char *  dirName  ) 

Get the directory structure (pointer) associated with a string name If the directory exists, return a pointer to it. If the directory doesn't exist, create it and return a pointer to it. If the directory cannot be created, report an error and return NULL.

Parameters:
[in] dirName Character string containing full path for directory.
Returns:
A pointer to a system DIR structure.
DIR* getDirectoryR ( char *  dirNameOrig  ) 

Get directory recursive; start a the left side and create or get each part of the directory.

Parameters:
[in] dirNameOrig Character string containing the full directory path
Returns:
A pointer to a system DIR structure.
long getMemoryReport (  ) 
char* getNextEmptyDirectory ( char *  baseDir  ) 

function to parse base output directory line find a directory that is empty, create one if needed by appending _v2, _v3, etc. up to _v9999, which is the max.

Parameters:
[in] baseDir Character string containing full path to a directory.
Returns:
a pointer to a character string that contains an empty output directory; NULL if an appropriate output directory cannot be found.
char* getParent ( char *  path  ) 

Get the parent part of the path.

Parameters:
[in] path String containing the full path.
Returns:
String containing the parent part of the path.
void getParentNChild ( char *  path,
char **  parentPtr,
char **  childPtr 
)

Split path into parent and child

Parameters:
[in] path String containing path to split.
[in,out] parentPtr Pointer to string containing parent name.
[in,out] childPtr Pointer to string containing child name.
bool isEmpty ( DIR *  pd  ) 

Determine if the directory is empty.

Parameters:
[in] pd Pointer to a DIR structure
Returns:
true if the directory is empty; false otherwise.
bool isReadable ( char *  pathname  ) 

Determine if the directory or file is accessible for reading.

Parameters:
[in] pathname Character string containing the name of the directory or file.
Returns:
true if the resource is accessible for reading.
bool isWritable ( char *  pathname  ) 

Determine if we have write permission to the directory.

Parameters:
[in] pathname Character string containing full path to directory.
Returns:
true is if write access; false otherwise.
int longestName ( char *  filenames[],
int  nFiles 
)
bool lowerStrNCmp ( const char *  str1,
const char *  str2,
int  n 
)

Compare two string up to n characters. Comparison is done with lowercase version of each string.

Parameters:
[in] str1 A string to compare.
[in] str2 Another string to compare.
[in] n maximum number of characters to compare.
Returns:
TRUE if strings are equal; FALSE otherwise.
char* nextToken (  ) 

stringTokenizer and nextToken work together to parse a character string into tokens, separated by spaces. nextToken finds the next set of non-white space characters, which is considered a token.

Returns:
The next token in the string or NULL if there are no more tokens.
void stringTokenizer ( char *  line  ) 

stringTokenizer and nextToken work together to parse a character string into tokens, separated by spaces. stringTokenizer intializes variables for breaking a string into tokens.

Parameters:
[in] line The string to break into words.
char* strip ( char *  aString  ) 
void td_free ( void *  mem,
size_t  size 
)
char* td_malloc ( size_t  size  ) 

Variable Documentation

long MemoryInUse = 0 [static]
int parserIdx = -1 [static]
char* parserLine = NULL [static]
int parserLineLength = -1 [static]
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines