OSspecific.H File Reference

Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be replaced or emulated on other systems. More...

Include dependency graph for OSspecific.H:

Go to the source code of this file.

Namespaces

 Foam
 Namespace for OpenFOAM.
 

Functions

pid_t pid ()
 Return the PID of this process. More...
 
pid_t ppid ()
 Return the parent PID of this process. More...
 
pid_t pgid ()
 Return the group PID of this process. More...
 
bool hasEnv (const std::string &envName)
 True if environment variable of given name is defined. More...
 
string getEnv (const std::string &envName)
 Get environment value for given envName. More...
 
bool setEnv (const word &name, const std::string &value, const bool overwrite)
 Set an environment variable, return true on success. More...
 
bool env (const std::string &envName)
 Deprecated(2020-05) check for existence of environment variable. More...
 
string hostName (bool full=false)
 Return the system's host name, as per hostname(1) More...
 
string domainName ()
 Return the system's domain name, as per hostname(1) with the '-d' option. More...
 
string userName ()
 Return the user's login name. More...
 
bool isAdministrator ()
 Is the current user the administrator (root) More...
 
fileName home ()
 Return home directory path name for the current user. More...
 
fileName home (const std::string &userName)
 Return home directory path name for a particular user. More...
 
fileName cwd ()
 The physical or logical current working directory path name. More...
 
fileName cwd (bool logical)
 The physical or logical current working directory path name. More...
 
bool chDir (const fileName &dir)
 Change current directory to the one specified and return true on success. More...
 
bool mkDir (const fileName &pathName, mode_t mode=0777)
 Make a directory and return an error if it could not be created. More...
 
bool chMod (const fileName &name, const mode_t mode)
 Set the file/directory mode, return true on success. More...
 
mode_t mode (const fileName &name, const bool followLink=true)
 Return the file mode, normally following symbolic links. More...
 
fileName::Type type (const fileName &name, const bool followLink=true)
 Return the file type: DIRECTORY or FILE, normally following symbolic links. More...
 
bool exists (const fileName &name, const bool checkGzip=true, const bool followLink=true)
 Does the name exist (as DIRECTORY or FILE) in the file system? More...
 
bool isDir (const fileName &name, const bool followLink=true)
 Does the name exist as a DIRECTORY in the file system? More...
 
bool isFile (const fileName &name, const bool checkGzip=true, const bool followLink=true)
 Does the name exist as a FILE in the file system? More...
 
off_t fileSize (const fileName &name, const bool followLink=true)
 Return size of file or -1 on failure (normally follows symbolic links). More...
 
time_t lastModified (const fileName &name, const bool followLink=true)
 Return time of last file modification (normally follows symbolic links). More...
 
double highResLastModified (const fileName &, const bool followLink=true)
 Return time of last file modification. More...
 
fileNameList readDir (const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
 Read a directory and return the entries as a fileName List. More...
 
bool cp (const fileName &src, const fileName &dst, const bool followLink=true)
 Copy the source to the destination (recursively if necessary). More...
 
bool ln (const fileName &src, const fileName &dst)
 Create a softlink. dst should not exist. Returns true if successful. More...
 
bool mv (const fileName &src, const fileName &dst, const bool followLink=false)
 Rename src to dst. More...
 
bool mvBak (const fileName &src, const std::string &ext="bak")
 Rename to a corresponding backup file. More...
 
bool rm (const fileName &file)
 Remove a file (or its gz equivalent), returning true if successful. More...
 
bool rmDir (const fileName &directory, const bool silent=false)
 Remove a directory and its contents (optionally silencing warnings) More...
 
unsigned int sleep (const unsigned int sec)
 Sleep for the specified number of seconds. More...
 
void fdClose (const int fd)
 Close file descriptor. More...
 
bool ping (const std::string &destName, const label port, const label timeOut)
 Check if machine is up by pinging given port. More...
 
bool ping (const std::string &host, const label timeOut=10)
 Check if machine is up by pinging port 22 (ssh) and 222 (rsh) More...
 
int system (const std::string &command, const bool bg=false)
 Execute the specified command via the shell. More...
 
int system (const UList< string > &command, const bool bg=false)
 Execute the specified command with arguments. More...
 
int system (const CStringList &command, const bool bg=false)
 Execute the specified command with arguments. More...
 
void * dlOpen (const fileName &libName, const bool check=true)
 Open a shared library and return handle to library. More...
 
void * dlOpen (const fileName &libName, std::string &errorMsg)
 Open a shared library and return handle to library. More...
 
label dlOpen (std::initializer_list< fileName > libNames, const bool check=true)
 Open shared libraries and return number of libraries loaded. More...
 
bool dlClose (void *handle)
 Close a dlopened library using handle. Return true if successful. More...
 
void * dlSymFind (void *handle, const std::string &symbol, bool required=false)
 Look for symbol in a dlopened library. More...
 
void * dlSym (void *handle, const std::string &symbol)
 Lookup a symbol in a dlopened library using handle to library. More...
 
void * dlSymFound (void *handle, const std::string &symbol)
 Check for symbol in a dlopened library. More...
 
fileNameList dlLoaded ()
 Return all loaded libraries. More...
 

Detailed Description

Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be replaced or emulated on other systems.

Original source file OSspecific.H

InNamespace Foam

Source files

Definition in file OSspecific.H.