Go to the documentation of this file.
45 #include <sys/types.h>
69 bool hasEnv(
const std::string& envName);
73 string getEnv(
const std::string& envName);
77 bool setEnv(
const word&
name,
const std::string& value,
const bool overwrite);
86 string hostName(
const bool full=
false);
112 fileName
cwd(
bool logical);
116 bool chDir(
const fileName& dir);
121 bool mkDir(
const fileName& pathName, mode_t
mode=0777);
129 mode_t
mode(
const fileName&
name,
const bool followLink=
true);
140 const fileName&
name,
141 const bool checkGzip=
true,
142 const bool followLink=
true
147 bool isDir(
const fileName&
name,
const bool followLink=
true);
154 const fileName&
name,
155 const bool checkGzip=
true,
156 const bool followLink=
true
161 off_t
fileSize(
const fileName&
name,
const bool followLink=
true);
175 const fileName& directory,
177 const bool filtergz=
true,
178 const bool followLink=
true
183 bool cp(
const fileName& src,
const fileName& dst,
const bool followLink=
true);
188 bool ln(
const fileName& src,
const fileName& dst);
196 const bool followLink=
false
202 bool mvBak(
const fileName& src,
const std::string& ext =
"bak");
206 bool rm(
const fileName& file);
211 bool rmDir(
const fileName& directory,
const bool silent=
false);
214 unsigned int sleep(
const unsigned int sec);
220 bool ping(
const std::string& destName,
const label port,
const label timeOut);
223 bool ping(
const std::string& host,
const label timeOut=10);
237 int system(
const std::string& command,
const bool bg =
false);
248 int system(
const UList<string>& command,
const bool bg =
false);
259 int system(
const CStringList& command,
const bool bg =
false);
264 void*
dlOpen(
const fileName& libName,
const bool check=
true);
269 void*
dlOpen(
const fileName& libName, std::string& errorMsg);
274 label
dlOpen(std::initializer_list<fileName> libNames,
const bool check=
true);
285 void*
dlSymFind(
void* handle,
const std::string& symbol,
bool required=
false);
289 inline void*
dlSym(
void* handle,
const std::string& symbol)
298 inline void*
dlSymFound(
void* handle,
const std::string& symbol)
string domainName()
Return the system's domain name, as per hostname(1) with the '-d' option.
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?
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
Type
Enumerations to handle directory entry types.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
void fdClose(const int fd)
Close file descriptor.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable, return true on success.
string getEnv(const std::string &envName)
Get environment value for given envName.
pid_t pgid()
Return the group PID of this process.
bool isAdministrator()
Is the current user the administrator (root)
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
bool hasEnv(const std::string &envName)
True if environment variable of given name is defined.
string userName()
Return the user's login name.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
void * dlSymFind(void *handle, const std::string &symbol, bool required=false)
Look for symbol in a dlopened library.
word name(const complex &c)
Return string representation of complex.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
pid_t pid()
Return the PID of this process.
pid_t ppid()
Return the parent PID of this process.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
bool ping(const std::string &destName, const label port, const label timeOut)
Check if machine is up by pinging given port.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
void * dlSymFound(void *handle, const std::string &symbol)
Check for symbol in a dlopened library.
List< fileName > fileNameList
A List of fileNames.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
bool chDir(const fileName &dir)
Change current directory to the one specified and return true on success.
fileName home()
Return home directory path name for the current user.
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
bool env(const std::string &envName)
Deprecated(2020-05) check for existence of environment variable.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
string hostName(const bool full=false)
Return the system's host name, as per hostname(1)
bool dlClose(void *handle)
Close a dlopened library using handle. Return true if successful.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
fileName cwd()
The physical or logical current working directory path name.
fileNameList dlLoaded()
Return all loaded libraries.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
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.
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?