47 const auto inputSize = ifs.
fileSize();
64 const uint64_t chunkSize =
68 : uint64_t(2*inputSize)
73 for (
int iter = 1; iter < 100000; ++iter)
80 const std::streamsize nread = iss.gcount();
85 || nread == std::numeric_limits<std::streamsize>::max()
94 beg += uint64_t(nread);
95 if (nread >= 0 && uint64_t(nread) < chunkSize)
114 const std::streamsize nread = iss.gcount();
119 || nread == std::numeric_limits<std::streamsize>::max()
127 buffer.
resize(label(nread));
139 if (!pathname.empty())
145 return readContents(ifs);
183 if (pathname.empty())
186 <<
"Cannot open empty file name"
198 <<
"Could not open file " << pathname
211 if (!ptr || this->
name().empty())
213 return std::streamsize(-1);
239 return std::streamsize(fileLen);
242 return std::streamsize(-1);
253 <<
"No stream allocated\n"
268 <<
"No stream allocated\n"
315 <<
"File " << this->
name() <<
" does not exist"
320 return const_cast<IFstream&
>(*this);
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 clear() noexcept
Clear the addressed list, i.e. set the size to zero.
label capacity() const noexcept
Size of the underlying storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
void setCapacity(const label len)
Alter the size of the underlying storage.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
virtual const fileName & name() const override
Read/write access to the name of the stream.
ISstream & get(char &c)
Get character(s).
IFstream & operator()() const
Return a non-const reference to const IFstream.
virtual void rewind() override
Rewind the stream so that it may be read again.
IFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption())
Construct from pathname, default or specified stream options.
virtual void print(Ostream &os) const override
Print stream description.
std::streamsize fileSize() const
Return the size of the underlying file (-1 on error). This corresponds to Foam::fileSize() but with e...
static DynamicList< char > readContents(const fileName &pathname)
Get file contents from specified file (compressed/uncompressed). Returns an empty list if the file ca...
virtual std::istream & stdStream() override
Access to underlying std::istream.
A simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
@ COMPRESSED
compression = true
void setBad() noexcept
Set stream state to be 'bad'.
bool good() const noexcept
True if next operation might succeed.
bool opened() const noexcept
True if stream has been opened.
label lineNumber_
The file line.
InfoProxy< IOstream > info() const noexcept
Return info proxy, used to print IOstream information to a stream.
void setClosed() noexcept
Set stream closed.
void setState(std::ios_base::iostate state) noexcept
Set stream state.
void setOpened() noexcept
Set stream opened.
Generic input stream using a standard (STL) stream.
virtual void rewind() override
Rewind the stream so that it may be read again.
virtual void print(Ostream &os) const override
Print stream description to Ostream.
ISstream(std::istream &is, const string &streamName, IOstreamOption streamOpt=IOstreamOption())
Construct wrapper around std::istream, set stream status.
virtual Istream & readRaw(char *data, std::streamsize count) override
Low-level raw binary read (without possible block delimiters). Reading into a null pointer behaves li...
virtual void rewind()=0
Rewind the stream so that it may be read again.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
T * data() 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.
A class for handling file names.
A wrapped std::ifstream with possible compression handling (igzstream) that behaves much like a std::...
void reopen_gz(const std::string &pathname)
Special 'rewind' method for compressed stream.
std::istream * get() noexcept
The stream pointer (ifstream or igzstream).
IOstreamOption::compressionType whichCompression() const
Which compression type?
ifstreamPointer() noexcept=default
Default construct (empty).
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
static void check(const int retVal, const char *what)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
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 ...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)