SORTIE Core C++ Documentation
Functions
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). More...
 
void ZipFile (string sFileName, string sAppPath)
 Zips a file with GZIP. More...
 
void AddFileToTarball (string sTarball, string sFileToAdd, string sAppPath)
 Adds a file to the end of a tarball. More...
 
void AddFileToNewTarball (string sTarball, string sFileToAdd, string sAppPath)
 Creates a new tarball and adds a file to it. More...
 
void DeleteThisFile (string sFile)
 Deletes a file. More...
 
bool DoesFileExist (string sFile)
 Checks for the existence of a file. More...
 
void LaunchProcess (string sFile, string sArgs, string sDir)
 Launches a process and waits for it to finish. More...
 
void ReplaceAll (std::string &source, const std::string &find, const std::string &replace)
 Finds all occurrences of one string within another and replaces them. More...
 

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

◆ AddFileToNewTarball()

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
sTarballFile name of tarball
sFileToAddFile name of the file to add to the tarball
sAppPathPath 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.

◆ AddFileToTarball()

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
sTarballFile name of tarball
sFileToAddFile name of the file to add to the tarball
sAppPathPath 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.

◆ DeleteThisFile()

void DeleteThisFile ( string  sFile)

Deletes a file.

Parameters
sFileFile name of the file to delete

◆ DoesFileExist()

bool DoesFileExist ( string  sFile)

Checks for the existence of a file.

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

◆ LaunchProcess()

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

Launches a process and waits for it to finish.

Parameters
sFileExecutable to launch
sArgsArguments to pass to process
sDirWorking directory

◆ ReplaceAll()

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
sourceString to search and replace within
findString to find
replaceString to replace with

◆ TarballSetup()

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
sAppPathPath 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.)

◆ ZipFile()

void ZipFile ( string  sFileName,
string  sAppPath 
)

Zips a file with GZIP.

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

Parameters
sFileNameFile to zip.
sAppPathPath 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.