76 open(pathname, streamOpt);
116 std::ios_base::openmode
mode 118 std::ios_base::out | std::ios_base::binary
123 mode |= std::ios_base::app;
141 const fileName pathname_gz(pathname +
".gz");
142 const fileName pathname_tmp(pathname +
"~tmp~");
154 const fileName& target = (atomic_ ? pathname_tmp : pathname_gz);
173 ptr_.reset(
new ogzstream(target,
mode));
181 <<
"No write support for gz compressed files (libz)" 182 <<
" : downgraded to UNCOMPRESSED" <<
nl 183 <<
"file: " << pathname_gz <<
endl;
190 const fileName& target = (atomic_ ? pathname_tmp : pathname);
209 ptr_.reset(
new std::ofstream(target,
mode));
216 const fileName& pathname,
225 IOstreamOption(IOstreamOption::ASCII, comp),
243 const std::ios_base::openmode
mode 245 std::ios_base::in | std::ios_base::binary
248 ptr_.reset(
new std::ifstream(pathname,
mode));
254 const fileName pathname_gz(pathname +
".gz");
260 ptr_.reset(
new igzstream(pathname_gz,
mode));
265 <<
"No read support for gz compressed files (libz)" 266 <<
" : could use 'gunzip' from the command-line" <<
nl 267 <<
"file: " << pathname_gz <<
endl 287 auto* gz =
dynamic_cast<igzstream*
>(ptr_.get());
298 (std::ios_base::in | std::ios_base::binary)
309 auto* gz =
dynamic_cast<ogzstream*
>(ptr_.get());
322 (std::ios_base::out | std::ios_base::binary)
330 (std::ios_base::out | std::ios_base::binary)
337 auto* file =
dynamic_cast<std::ofstream*
>(ptr_.get());
355 (std::ios_base::out | std::ios_base::binary)
363 (std::ios_base::out | std::ios_base::binary)
373 if (!atomic_ || pathname.empty())
return;
376 auto* gz =
dynamic_cast<ogzstream*
>(ptr_.get());
386 (pathname +
"~tmp~").c_str(),
387 (pathname +
".gz").c_str()
393 auto* file =
dynamic_cast<std::ofstream*
>(ptr_.get());
405 (pathname +
"~tmp~").c_str(),
417 if (dynamic_cast<const igzstream*>(ptr_.get()))
419 return IOstreamOption::compressionType::COMPRESSED;
423 return IOstreamOption::compressionType::UNCOMPRESSED;
431 if (dynamic_cast<const ogzstream*>(ptr_.get()))
433 return IOstreamOption::compressionType::COMPRESSED;
437 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.
A simple container for options an IOstream can normally have.
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)
compressionType compression() const noexcept
Get the stream compression.
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?
void open(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption())
Attempts to open the specified file for reading.
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.