43 const bool writeOnProc,
49 if (fileOperation::debug)
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 =
157 while (fileLength > 0)
159 const uint64_t sendSize = std::min(fileLength, maxChunkSize);
160 fileLength -= sendSize;
184 const bool writeOnProc,
196 if (fileOperation::debug)
200 <<
" on master processor and writing a copy to " << dst
207 srcType = src.type(
false);
212 reinterpret_cast<char*
>(&srcType),
363 const bool writeOnProc,
364 const fileName& srcPath,
365 const fileName& dstPath
369 DynamicList<char> fileContents;
387 destFile = destFile/src.name();
401 const word srcDirName = src.name();
402 if (destFile.name() != srcDirName)
404 destFile /= srcDirName;
415 (dstPath.empty() ? srcPath : dstPath),
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void resize_nocopy(const label len)
Alter addressable list size, allocating new space if required without necessarily recovering old cont...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
const T1 & first() const noexcept
Access the first element.
const T2 & second() const noexcept
Access the second element.
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage,.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool is_subrank(const label communicator=worldComm)
True if process corresponds to a sub-rank in the given communicator.
static int maxCommsSize
Optional maximum message size (bytes).
@ broadcast
broadcast [MPI]
A class for handling file names.
Type
Enumerations to handle directory entry types.
@ SYMLINK
A symbolic link.
@ UNDEFINED
Undefined type.
Type type(bool followLink=true, bool checkGzip=false) const
Return the directory entry type: UNDEFINED, FILE, DIRECTORY (or SYMLINK).
static std::string path(const std::string &str)
Return directory path name (part before last /).
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 comm() const noexcept
Communicator to use.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
fileName readLink(const fileName &link)
Return the contents (target) of a symlink.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
List< fileName > fileNameList
List of fileName.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
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.
static void broadcastFile_single(const label comm, const bool writeOnProc, const fileName &srcName, const fileName &dstName, DynamicList< char > &buffer)
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
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.