OpenFOAM logo
Open Source CFD Toolkit

OSspecific.H File Reference


Detailed Description

View OSspecific.H
License
This file is part of OpenFOAM.

OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Functions used by FOAM which are specific to the unix operating system,
and need to be replaced or simulated on any other system.

Definition in file OSspecific.H.

Go to the source code of this file.

Namespaces

namespace  Foam

Functions

pid_t pid ()
 Return the PID of this process.
pid_t ppid ()
 Return the parent PID of this process.
pid_t pgid ()
 Return the group PID of this process.
bool env (const word &)
 Return true if environment variable of given name is defined.
string getEnv (const word &name)
 Return environment variable of given name.
bool setEnv (const word &name, const string &value, const bool overwrite)
 Set an environment variable.
word hostName ()
 Return the system's host name.
word userName ()
 Return the user's login name.
fileName home ()
 Return home directory path name.
fileName cwd ()
 Return home directory path name.
bool chDir (const fileName &dir)
 Change the current directory to the one given and return true,.
fileName dotFoam (const fileName &name)
 Return .foam directory path name.
bool mkDir (const fileName &, mode_t=0754)
 Make a directory and return an error if it could not be created.
bool chmod (const fileName &, const mode_t=0640)
 Set the file mode.
mode_t mode (const fileName &)
 Return the file mode.
fileName::Type type (const fileName &)
 Return the file type: FILE or DIRECTORY.
bool exists (const fileName &name)
 Does the name exist in the filing system?
bool file (const fileName &)
 Does the file exist?
bool dir (const fileName &)
 Does the directory exist?
off_t size (const fileName &)
 Return size of file.
time_t lastModified (const fileName &)
 Return time of last file modification.
fileNameList readDir (const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true)
 Read a directory and return the entries as a string list.
bool cp (const fileName &srcFile, const fileName &destFile)
 Copy, recursively if necessary, the source to the destination.
bool mv (const fileName &srcFile, const fileName &destFile)
 Rename srcFile destFile.
bool rm (const fileName &)
 Remove a file returning true if successful otherwise false.
bool rmDir (const fileName &)
 Remove a dirctory and it's contents.
unsigned int sleep (const unsigned int)
 Sleep for the specified number of seconds.
void fdClose (const int)
 Close file descriptor.
bool ping (const word &, const label port, const label timeOut)
 Check if machine is up by pinging given port.
bool ping (const word &, const label timeOut=10)
 Check if machine is up by ping port 22 = ssh and 222 = rsh.


Function Documentation

bool chDir const fileName &  dir  ) 
 

Change the current directory to the one given and return true,.

else return false

bool chmod const fileName &  ,
const   mode_t = 0640
 

Set the file mode.

bool cp const fileName &  srcFile,
const fileName &  destFile
 

Copy, recursively if necessary, the source to the destination.

Referenced by specieThermo::a(), specieThermo::cv(), and specieThermo::specieThermo().

fileName cwd  ) 
 

Return home directory path name.

bool dir const fileName &   ) 
 

Does the directory exist?

Referenced by PrimitivePatch< face, IndirectList, const pointField & >::isInternalEdge().

fileName dotFoam const fileName &  name  ) 
 

Return .foam directory path name.

bool env const word &   ) 
 

Return true if environment variable of given name is defined.

bool exists const fileName &  name  ) 
 

Does the name exist in the filing system?

void fdClose const   int  ) 
 

Close file descriptor.

bool file const fileName &   ) 
 

Does the file exist?

string getEnv const word &  name  ) 
 

Return environment variable of given name.

fileName home  ) 
 

Return home directory path name.

word hostName  ) 
 

Return the system's host name.

time_t lastModified const fileName &   ) 
 

Return time of last file modification.

bool mkDir const fileName &  ,
mode_t  = 0754
 

Make a directory and return an error if it could not be created.

and does not already exist

mode_t mode const fileName &   ) 
 

Return the file mode.

bool mv const fileName &  srcFile,
const fileName &  destFile
 

Rename srcFile destFile.

pid_t pgid  ) 
 

Return the group PID of this process.

pid_t pid  ) 
 

Return the PID of this process.

bool ping const word &  ,
const label  timeOut = 10
 

Check if machine is up by ping port 22 = ssh and 222 = rsh.

bool ping const word &  ,
const label  port,
const label  timeOut
 

Check if machine is up by pinging given port.

pid_t ppid  ) 
 

Return the parent PID of this process.

fileNameList readDir const fileName &  ,
const fileName::Type  = fileName::FILE,
const bool  filtergz = true
 

Read a directory and return the entries as a string list.

bool rm const fileName &   ) 
 

Remove a file returning true if successful otherwise false.

bool rmDir const fileName &   ) 
 

Remove a dirctory and it's contents.

bool setEnv const word &  name,
const string &  value,
const bool  overwrite
 

Set an environment variable.

off_t size const fileName &   ) 
 

Return size of file.

Referenced by areaMesh::areaMesh(), FIFOStack< word >::bottom(), fvPatch::boundaryMesh(), UList::checkSize(), FixedList::checkSize(), zeroGradientFvPatchField::clone(), zeroGradientFaPatchField::clone(), edgeMesh::edgeMesh(), elementMesh::elementMesh(), fvMeshLduAddressing::fvMeshLduAddressing(), GeoMesh< fvMesh >::GeoMesh(), HashSet< label, Hash< label > >::HashSet(), lduAddressingFaMesh::lduAddressingFaMesh(), cellMatcher::nextVert(), pointMesh::operator()(), DynamicList::operator()(), PackedList::PackedList(), fvMeshSubset::patchFieldSubset::patchFieldSubset(), TetPointPatchField< tetPolyPatchField, tetPolyPatch, Type >::setBoundaryCondition(), DynamicList::shrink(), faPatch::size(), surfaceMesh::surfaceMesh(), tetPointMesh::tetPointMesh(), thirdBodyEfficiencies::thirdBodyEfficiencies(), ITstream::tokenIndex(), LIFOStack::top(), and volMesh::volMesh().

unsigned int sleep const unsigned  int  ) 
 

Sleep for the specified number of seconds.

fileName::Type type const fileName &   ) 
 

Return the file type: FILE or DIRECTORY.

Referenced by TetPointPatchField< tetPolyPatchField, tetPolyPatch, Type >::addDiag(), TetPointPatchField< tetPolyPatchField, tetPolyPatch, Type >::addSource(), cellInfo::cellInfo(), TetPointPatchField< tetPolyPatchField, tetPolyPatch, Type >::initAddField(), faPatchField::initEvaluate(), lduCoupledInterface::updateInterfaceMatrix(), and faPatchField::valueInternalCoeffs().

word userName  ) 
 

Return the user's login name.

For further information go to www.openfoam.org