39#ifndef Foam_OSspecific_H
40#define Foam_OSspecific_H
69bool hasEnv(
const std::string& envName);
73string getEnv(
const std::string& envName);
77bool setEnv(
const word&
name,
const std::string& value,
const bool overwrite);
118fileName
cwd(
bool logical);
122bool chDir(const fileName& dir);
127bool mkDir(const fileName& pathName, mode_t
mode=0777);
135mode_t
mode(const fileName&
name, const
bool followLink=true);
139fileName::Type
type(const fileName&
name, const
bool followLink=true);
146 const fileName&
name,
147 const
bool checkGzip=true,
148 const
bool followLink=true
153bool isDir(const fileName&
name, const
bool followLink=true);
160 const fileName&
name,
161 const
bool checkGzip=true,
162 const
bool followLink=true
167off_t
fileSize(const fileName&
name, const
bool followLink=true);
181 const fileName& directory,
182 const fileName::Type
type=fileName::FILE,
183 const
bool filtergz=true,
184 const
bool followLink=true
189bool cp(const fileName& src, const fileName& dst, const
bool followLink=true);
194bool ln(const fileName& src, const fileName& dst);
202 const
bool followLink=false
208bool mvBak(const fileName& src, const std::
string& ext = "bak");
212bool rm(const fileName& file);
217bool rmDir(const fileName& directory, const
bool silent=false);
220unsigned int sleep(const
unsigned int sec);
226bool ping(const std::
string& destName, const label port, const label timeOut);
229bool ping(const std::
string& host, const label timeOut=10);
243int system(const std::
string& command, const
bool bg = false);
254int system(const UList<
string>& command, const
bool bg = false);
265int system(const CStringList& command, const
bool bg = false);
270void*
dlOpen(const fileName& libName, const
bool check=true);
275void*
dlOpen(const fileName& libName, std::
string& errorMsg);
280label
dlOpen(std::initializer_list<fileName> libNames, const
bool check=true);
291void*
dlSymFind(
void* handle, const std::
string& symbol,
bool required=false);
295inline
void*
dlSym(
void* handle, const std::
string& symbol)
304inline void*
dlSymFound(
void* handle,
const std::string& symbol)
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
fileName cwd()
The physical or logical current working directory path name.
string getEnv(const std::string &envName)
Get environment value for given envName.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
List< fileName > fileNameList
A List of fileNames.
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
void fdClose(const int fd)
Close file descriptor.
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?
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
bool isAdministrator()
Is the current user the administrator (root)
bool dlClose(void *handle)
Close a dlopened library using handle. Return true if successful.
bool env(const std::string &envName)
Deprecated(2020-05) check for existence of environment variable.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
static void check(const int retVal, const char *what)
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
string userName()
Return the user's login name.
pid_t pgid()
Return the group PID of this process.
string hostName()
Return the system's host name, as per hostname(1)
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
void * dlSymFind(void *handle, const std::string &symbol, bool required=false)
Look for symbol in a dlopened library.
bool ping(const std::string &destName, 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.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
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.
pid_t pid()
Return the PID of this process.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
fileNameList dlLoaded()
Return all loaded libraries.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
fileName home()
Return home directory path name for the current user.
string domainName()
Deprecated(2022-01) domain name resolution may be unreliable.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
void * dlSymFound(void *handle, const std::string &symbol)
Check for symbol in a dlopened library.
bool hasEnv(const std::string &envName)
True if environment variable of given name is defined.
bool chDir(const fileName &dir)
Change current directory to the one specified and return true on success.
const volScalarField & cp
#define FOAM_DEPRECATED_FOR(since, replacement)