libCombine
C++ library for working with the COMBINE Archive format
Loading...
Searching...
No Matches
Util Class Reference

Static Public Member Functions

static std::string getTempPath ()
 
static std::string getTempFilename (const std::string &prefix="temp", const std::string &ext=".tmp")
 constructs a new temp file name using the current milliseconds. More...
 
static unsigned long getCurrentMilliseconds ()
 
static void copyFile (const std::string &source, const std::string &destination)
 copies the source file to the destination More...
 
static void copyStream (std::istream &in, std::ostream &out)
 copies in to out More...
 
static std::string getExtension (const std::string &fileName)
 returns the extension of the given filename (not including the dot) More...
 
static bool removeFileOrFolder (const std::string &path)
 Removes the specified file or folder. More...
 
static std::string getDefaultTempDir ()
 Get the Default Temp Dir object. More...
 
static void setDefaultTempDir (const std::string &defaultDir)
 Set the Default Temp Dir object. More...
 

Member Function Documentation

◆ copyFile()

static void Util::copyFile ( const std::string &  source,
const std::string &  destination 
)
static

copies the source file to the destination

Parameters
sourcesource file name
destinationdestination file name

◆ copyStream()

static void Util::copyStream ( std::istream &  in,
std::ostream &  out 
)
static

copies in to out

Parameters
ininput stream
outoutput stream

◆ getCurrentMilliseconds()

static unsigned long Util::getCurrentMilliseconds ( )
static
Returns
current milliseconds since 1970 on this system

◆ getDefaultTempDir()

static std::string Util::getDefaultTempDir ( )
static

Get the Default Temp Dir object.

Returns
std::string of the default directory

◆ getExtension()

static std::string Util::getExtension ( const std::string &  fileName)
static

returns the extension of the given filename (not including the dot)

Parameters
fileNamethe filename
Returns
the extension if found, otherwise an empty string.

◆ getTempFilename()

static std::string Util::getTempFilename ( const std::string &  prefix = "temp",
const std::string &  ext = ".tmp" 
)
static

constructs a new temp file name using the current milliseconds.

The format of the temp file will be:

temp_path + "/" + prefix + milliseconds + ext

Parameters
prefixoptional prefix to be used (will be "temp" otherwise)
extoptional extension to be used (will be ".tmp" otherwise)
Returns
the temp filename

◆ getTempPath()

static std::string Util::getTempPath ( )
static
Returns
the temp path or "." if the temp path could not be located

◆ removeFileOrFolder()

static bool Util::removeFileOrFolder ( const std::string &  path)
static

Removes the specified file or folder.

If it is a folder its contents will be removed recursively.

◆ setDefaultTempDir()

static void Util::setDefaultTempDir ( const std::string &  defaultDir)
static

Set the Default Temp Dir object.

Parameters
defaultDirthe default directory