Minors adjustments to POSIX.C

This commit is contained in:
Martin Beaudoin 2018-02-21 21:32:08 -05:00
parent 23b739f1c8
commit a9b6d1beb1

View file

@ -555,6 +555,7 @@ bool Foam::chMod(const fileName& name, const mode_t m)
} }
// Return the file mode
mode_t Foam::mode(const fileName& name) mode_t Foam::mode(const fileName& name)
{ {
fileStat fileStatus(name); fileStat fileStatus(name);
@ -569,6 +570,7 @@ mode_t Foam::mode(const fileName& name)
} }
// Return the file type: FILE or DIRECTORY
Foam::fileName::Type Foam::type(const fileName& name) Foam::fileName::Type Foam::type(const fileName& name)
{ {
mode_t m = mode(name); mode_t m = mode(name);
@ -588,24 +590,28 @@ Foam::fileName::Type Foam::type(const fileName& name)
} }
// Does the name exist in the filing system?
bool Foam::exists(const fileName& name, const bool checkGzip) bool Foam::exists(const fileName& name, const bool checkGzip)
{ {
return mode(name) || isFile(name, checkGzip); return mode(name) || isFile(name, checkGzip);
} }
// Does the directory exist?
bool Foam::isDir(const fileName& name) bool Foam::isDir(const fileName& name)
{ {
return S_ISDIR(mode(name)); return S_ISDIR(mode(name));
} }
// Does the file exist?
bool Foam::isFile(const fileName& name, const bool checkGzip) bool Foam::isFile(const fileName& name, const bool checkGzip)
{ {
return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz"))); return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz")));
} }
// Return size of file
off_t Foam::fileSize(const fileName& name) off_t Foam::fileSize(const fileName& name)
{ {
fileStat fileStatus(name); fileStat fileStatus(name);
@ -620,6 +626,7 @@ off_t Foam::fileSize(const fileName& name)
} }
// Return time of last file modification
time_t Foam::lastModified(const fileName& name) time_t Foam::lastModified(const fileName& name)
{ {
fileStat fileStatus(name); fileStat fileStatus(name);
@ -634,6 +641,7 @@ time_t Foam::lastModified(const fileName& name)
} }
// Read a directory and return the entries as a string list
Foam::fileNameList Foam::readDir Foam::fileNameList Foam::readDir
( (
const fileName& directory, const fileName& directory,
@ -729,6 +737,7 @@ Foam::fileNameList Foam::readDir
} }
// Copy, recursively if necessary, the source to the destination
bool Foam::cp(const fileName& src, const fileName& dest) bool Foam::cp(const fileName& src, const fileName& dest)
{ {
// Make sure source exists. // Make sure source exists.
@ -828,6 +837,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
} }
// Create a softlink. dst should not exist. Returns true if successful.
bool Foam::ln(const fileName& src, const fileName& dst) bool Foam::ln(const fileName& src, const fileName& dst)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -865,6 +875,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
} }
// Rename srcFile dstFile
bool Foam::mv(const fileName& src, const fileName& dst) bool Foam::mv(const fileName& src, const fileName& dst)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -890,6 +901,8 @@ bool Foam::mv(const fileName& src, const fileName& dst)
} }
//- Rename to a corresponding backup file
// If the backup file already exists, attempt with "01" .. "99" index
bool Foam::mvBak(const fileName& src, const std::string& ext) bool Foam::mvBak(const fileName& src, const std::string& ext)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -927,6 +940,8 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
} }
// Remove a file, returning true if successful otherwise false
bool Foam::rm(const fileName& file) bool Foam::rm(const fileName& file)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -947,6 +962,7 @@ bool Foam::rm(const fileName& file)
} }
// Remove a dirctory and its contents
bool Foam::rmDir(const fileName& directory) bool Foam::rmDir(const fileName& directory)
{ {
if (POSIX::debug) if (POSIX::debug)
@ -1236,7 +1252,7 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
} }
} }
#ifdef NOT_SURE_HOW_TO_USE_THIS
static int collectLibsCallback static int collectLibsCallback
( (
struct dl_phdr_info *info, struct dl_phdr_info *info,
@ -1263,6 +1279,7 @@ Foam::fileNameList Foam::dlLoaded()
} }
return libs; return libs;
} }
#endif
void Foam::osRandomSeed(const label seed) void Foam::osRandomSeed(const label seed)