72 const std::ios_base::openmode
mode 74 std::ios_base::in | std::ios_base::binary
77 ptr_.reset(
new std::ifstream(pathname,
mode));
83 const fileName pathname_gz(pathname +
".gz");
89 ptr_.reset(
new igzstream(pathname_gz,
mode));
94 <<
"No read support for gz compressed files (libz)" 95 <<
" : could use 'gunzip' from the command-line" <<
nl 96 <<
"file: " << pathname_gz <<
endl 138 std::ios_base::openmode
mode 140 std::ios_base::out | std::ios_base::binary
145 mode |= std::ios_base::app;
163 const fileName pathname_gz(pathname +
".gz");
164 const fileName pathname_tmp(pathname +
"~tmp~");
176 const fileName& target = (atomic_ ? pathname_tmp : pathname_gz);
195 ptr_.reset(
new ogzstream(target,
mode));
203 <<
"No write support for gz compressed files (libz)" 204 <<
" : downgraded to UNCOMPRESSED" <<
nl 205 <<
"file: " << pathname_gz <<
endl;
212 const fileName& target = (atomic_ ? pathname_tmp : pathname);
231 ptr_.reset(
new std::ofstream(target,
mode));
241 auto* gz =
dynamic_cast<igzstream*
>(ptr_.get());
252 (std::ios_base::in | std::ios_base::binary)
263 auto* gz =
dynamic_cast<ogzstream*
>(ptr_.get());
276 (std::ios_base::out | std::ios_base::binary)
284 (std::ios_base::out | std::ios_base::binary)
291 auto* file =
dynamic_cast<std::ofstream*
>(ptr_.get());
309 (std::ios_base::out | std::ios_base::binary)
317 (std::ios_base::out | std::ios_base::binary)
327 if (!atomic_ || pathname.empty())
return;
330 auto* gz =
dynamic_cast<ogzstream*
>(ptr_.get());
340 (pathname +
"~tmp~").c_str(),
341 (pathname +
".gz").c_str()
347 auto* file =
dynamic_cast<std::ofstream*
>(ptr_.get());
359 (pathname +
"~tmp~").c_str(),
371 if (dynamic_cast<const igzstream*>(ptr_.get()))
373 return IOstreamOption::compressionType::COMPRESSED;
377 return IOstreamOption::compressionType::UNCOMPRESSED;
385 if (dynamic_cast<const ogzstream*>(ptr_.get()))
387 return IOstreamOption::compressionType::COMPRESSED;
391 return IOstreamOption::compressionType::UNCOMPRESSED;
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOstreamOption::compressionType whichCompression() const
Which compression type?
Trivial output stream for calculating byte counts.
static bool supports_gz()
True if compiled with libz support.
constexpr char nl
The newline '\n' character (0x0a)
ofstreamPointer() noexcept
Default construct (empty)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool supports_gz()
True if compiled with libz support.
void reopen_gz(const std::string &pathname)
Special 'rewind' method for compressed stream.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
void reopen(const std::string &pathname)
Reopen for compressed/non-compressed.
ifstreamPointer() noexcept=default
Default construct (empty)
void close(const std::string &pathname)
Close stream and rename file.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
IOstreamOption::compressionType whichCompression() const
Which compression type?
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Type
Enumerations to handle directory entry types.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.