PlatformFuncs.h File Reference

These are functions which use platform-specific code. More...

#include <string>

Functions

bool TarballSetup (string sAppPath)
 Verifies that gzip and tar are where we expect them to be (in the same directory as the executable).
void ZipFile (string sFileName, string sAppPath)
 Zips a file with GZIP.
void AddFileToTarball (string sTarball, string sFileToAdd, string sAppPath)
 Adds a file to the end of a tarball.
void AddFileToNewTarball (string sTarball, string sFileToAdd, string sAppPath)
 Creates a new tarball and adds a file to it.
void DeleteThisFile (string sFile)
 Deletes a file.
bool DoesFileExist (string sFile)
 Checks for the existence of a file.
void LaunchProcess (string sFile, string sArgs, string sDir)
 Launches a process and waits for it to finish.
void ReplaceAll (std::string &source, const std::string &find, const std::string &replace)
 Finds all occurrences of one string within another and replaces them.


Detailed Description

These are functions which use platform-specific code.

Copyright 2003 Charles D. Canham.

Author:
Lora E. Murphy

Edit history:
-----------------
April 28, 2004 - Submitted as beta (LEM)
June 20, 2007 - New Linux versions of the functions, based on code originally written by Daniel Lipsitt, to whom great thanks is owed (LEM)

Function Documentation

void AddFileToNewTarball ( string  sTarball,
string  sFileToAdd,
string  sAppPath 
)

Creates a new tarball and adds a file to it.

Any existing tarball of that name will be overwritten. If the tarball does not exist, it will be created. The file to add can be either zipped or not zipped.

Parameters:
sTarball File name of tarball
sFileToAdd File name of the file to add to the tarball
sAppPath Path to the main application, ending with the path separator. The TAR executable is expected to be in the same path. For Linux, tar is expected to be somewhere in the user's PATH.

void AddFileToTarball ( string  sTarball,
string  sFileToAdd,
string  sAppPath 
)

Adds a file to the end of a tarball.

If the tarball does not exist, it will be created. The file to add can be either zipped or not zipped.

Parameters:
sTarball File name of tarball
sFileToAdd File name of the file to add to the tarball
sAppPath Path to the main application, ending with the path separator. The TAR executable is expected to be in the same path. For Linux, tar is expected to be somewhere in the user's PATH.

void DeleteThisFile ( string  sFile  ) 

Deletes a file.

Parameters:
sFile File name of the file to delete

bool DoesFileExist ( string  sFile  ) 

Checks for the existence of a file.

Parameters:
sFile File name of the file to check for existence
Returns:
True if the file exists, false if it doesn't

void LaunchProcess ( string  sFile,
string  sArgs,
string  sDir 
)

Launches a process and waits for it to finish.

Parameters:
sFile Executable to launch
sArgs Arguments to pass to process
sDir Working directory

void ReplaceAll ( std::string &  source,
const std::string &  find,
const std::string &  replace 
)

Finds all occurrences of one string within another and replaces them.

Parameters:
source String to search and replace within
find String to find
replace String to replace with

bool TarballSetup ( string  sAppPath  ) 

Verifies that gzip and tar are where we expect them to be (in the same directory as the executable).

This should be called before either of the functions below and a fatal error thrown if it returns false. For Linux, this function always returns true.

Parameters:
sAppPath Path to the main application, ending with the path separator. The executables are expected to be in the same path.
Returns:
true if the executables are where they should be. Otherwise, false. (For Linux always true.)

void ZipFile ( string  sFileName,
string  sAppPath 
)

Zips a file with GZIP.

If the file does not exist, the function does nothing.

Parameters:
sFileName File to zip.
sAppPath Path to the main application, ending with the path separator. For Windows, the GZIP executable is expected to be in the same path. For Linux, gzip is expected to be somewhere in the user's PATH.


Generated on Tue Apr 19 13:56:04 2011 for SORTIE Core C++ Documentation by  doxygen 1.5.6