43 const bool writeOnProc,
52 <<
"Reading file " << srcName
53 <<
" on master processor and copying to " << dstName
70 std::unique_ptr<std::ifstream> srcStream;
71 std::unique_ptr<std::ofstream> dstStream;
79 lengthAndMode.
first() = uint64_t(fileLen);
88 std::ios_base::in | std::ios_base::binary
91 if (!srcStream->good())
94 <<
"Could not open file for reading!" 105 ? (srcName != dstName)
120 std::ios_base::out | std::ios_base::binary
124 if (!dstStream->good())
127 if (!dstStream->good())
129 dstStream.reset(
nullptr);
140 reinterpret_cast<char*>(&lengthAndMode),
141 sizeof(lengthAndMode),
145 uint64_t fileLength = lengthAndMode.
first();
147 const uint64_t maxChunkSize =
155 while (fileLength > 0)
157 const uint64_t sendSize =
min(fileLength, maxChunkSize);
158 fileLength -= sendSize;
182 const bool writeOnProc,
186 DynamicList<char>& buffer
198 <<
" on master processor and writing a copy to " << dst
205 srcType = src.type(
false);
210 reinterpret_cast<char*>(&srcType),
264 for (
const fileName& item : files)
294 for (
const fileName& item : files)
325 for (
const fileName& item : dirs)
361 const bool writeOnProc,
385 destFile = destFile/src.name();
399 const word srcDirName = src.name();
400 if (destFile.name() != srcDirName)
402 destFile /= srcDirName;
413 (dstPath.empty() ? srcPath : dstPath),
A class for handling file names.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
fileName readLink(const fileName &link)
Return the contents (target) of a symlink.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static int maxCommsSize
Optional maximum message size (bytes)
static bool broadcastFile_recursive(const label comm, const bool writeOnProc, const fileName &src, const fileName &dst, DynamicList< char > &buffer)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A traits class, which is primarily used for primitives and vector-space.
static std::string path(const std::string &str)
Return directory path name (part before last /)
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
virtual bool broadcastCopy(const label comm, const bool writeOnProc, const fileName &src, const fileName &dst) const
Read dir/file (recursively if necessary) on master of the communicator, send and write contents to al...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
int debug
Static debugging option.
static bool is_subrank(const label communicator=worldComm)
True if process corresponds to a sub-rank in the given communicator.
static void broadcastFile_single(const label comm, const bool writeOnProc, const fileName &srcName, const fileName &dstName, DynamicList< char > &buffer)
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static bool broadcast(char *buf, const std::streamsize bufSize, const label communicator, const int rootProcNo=masterNo())
Broadcast buffer contents to all processes in given communicator. The sizes must match on all process...
label comm() const noexcept
Communicator to use.
const T2 & second() const noexcept
Access the second element.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
const T1 & first() const noexcept
Access the first element.
List< fileName > fileNameList
List of fileName.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
Type
Enumerations to handle directory entry types.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
#define InfoInFunction
Report an information message using Foam::Info.