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();
94 beg += uint64_t(nread);
95 if (nread >= 0 && uint64_t(nread) < chunkSize)
114 const std::streamsize nread = iss.gcount();
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" 313 <<
"File " << this->
name() <<
" does not exist" 318 return const_cast<IFstream&
>(*this);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
label lineNumber_
The file line.
A wrapped std::ifstream with possible compression handling (igzstream) that behaves much like a std::...
bool opened() const noexcept
True if stream has been opened.
IFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption())
Construct from pathname, default or specified stream options.
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...
A class for handling file names.
virtual void rewind() override
Rewind the stream so that it may be read again.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
void setClosed() noexcept
Set stream closed.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void setState(std::ios_base::iostate state) noexcept
Set stream state.
IOstreamOption::compressionType whichCompression() const
Which compression type?
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
Ostream & endl(Ostream &os)
Add newline and flush stream.
InfoProxy< IOstream > info() const noexcept
Return info proxy, used to print IOstream information to a stream.
void reopen_gz(const std::string &pathname)
Special 'rewind' method for compressed stream.
void setCapacity(const label len)
Alter the size of the underlying storage.
A simple container for options an IOstream can normally have.
label capacity() const noexcept
Size of the underlying storage.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual void rewind() override
Rewind the stream so that it may be read again.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
std::istream * get() noexcept
The stream pointer (ifstream or igzstream)
virtual const fileName & name() const override
The name of the input serial stream. (eg, the name of the Fstream file name)
errorManip< error > abort(error &err)
virtual std::istream & stdStream() override
Access to underlying std::istream.
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
compressionType compression() const noexcept
Get the stream compression.
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
static void check(const int retVal, const char *what)
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
std::streamsize fileSize() const
Return the size of the underlying file (-1 on error). This corresponds to Foam::fileSize() but with e...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Generic input stream using a standard (STL) stream.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool good() const noexcept
True if next operation might succeed.
static DynamicList< char > readContents(const fileName &pathname)
Get file contents from specified file (compressed/uncompressed). Returns an empty list if the file ca...
IFstream & operator()() const
Return a non-const reference to const IFstream.
void setOpened() noexcept
Set stream opened.
virtual void print(Ostream &os) const override
Print stream description.
virtual void print(Ostream &os) const override
Print stream description to Ostream.
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the List data.
void setBad() noexcept
Set stream state to be 'bad'.
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.