77 "Bad state: neither ronly nor wonly seen");
80 if (!
fUrl.
Set(url,
"|app|bck=|", emsg))
return false;
87 if (!
fUrl.
Set(url,
"", emsg))
return false;
93 string(
"fopen() for '") +
fUrl.
Path() +
"' failed: ",
108 "Bad state: Read() called but fIStream=false");
110 throw Rexception(
"Rw11VirtStream::Read",
"Bad state: file not open");
113 size_t irc = ::fread(data, 1, count,
fFile);
114 if (irc == 0 && ::ferror(
fFile)) {
115 emsg.
InitErrno(
"Rw11VirtStream::Read()",
"fread() failed: ", errno);
130 "Bad state: Write() called but fOStream=false");
132 throw Rexception(
"Rw11VirtStream::Write",
"Bad state: file not open");
135 size_t irc = ::fwrite(data, 1, count,
fFile);
137 emsg.
InitErrno(
"Rw11VirtStream::Write()",
"fwrite() failed: ", errno);
152 throw Rexception(
"Rw11VirtStream::Write",
"Bad state: file not open");
155 size_t irc = ::fflush(
fFile);
157 emsg.
InitErrno(
"Rw11VirtStream::Flush()",
"fflush() failed: ", errno);
170 throw Rexception(
"Rw11VirtStream::Tell",
"Bad state: file not open");
173 long irc = ::ftell(
fFile);
175 emsg.
InitErrno(
"Rw11VirtStream::Tell()",
"ftell() failed: ", errno);
188 throw Rexception(
"Rw11VirtStream::Seek",
"Bad state: file not open");
191 int whence = SEEK_SET;
196 int irc = ::fseek(
fFile, pos, whence);
199 emsg.
InitErrno(
"Rw11VirtStream::Seek()",
"fseek() failed: ", errno);
229 os << bl << (text?text:
"--") <<
"Rw11VirtStream @ " <<
this << endl;
233 os << bl <<
" fFile: " <<
fFile << endl;
235 os << bl <<
" fFile.tell " << ::ftell(
fFile) << endl;
236 os << bl <<
" fFile.error " << ::ferror(
fFile) << endl;
237 os << bl <<
" fFile.eof " << ::feof(
fFile) << endl;
251 unique_ptr<Rw11VirtStream> up;
253 if (!up->Open(url, emsg)) up.reset();
void InitErrno(const std::string &meth, const std::string &text, int errnum)
FIXME_docs.
I/O appicator to generate fill characters.
bool FindOpt(const std::string &name) const
FIXME_docs.
bool Set(const std::string &url, const std::string &optlist, RerrMsg &emsg)
FIXME_docs.
const std::string & Path() const
FIXME_docs.
void Inc(size_t ind, double val=1.)
FIXME_docs.
void Define(size_t ind, const std::string &name, const std::string &text)
FIXME_docs.
const std::string & AttachOpts() const
FIXME_docs.
bool fIStream
is input (read only) stream
bool fOStream
is output (write only) stream
Rw11VirtStream(Rw11Unit *punit)
Default constructor.
bool Write(const uint8_t *data, size_t count, RerrMsg &emsg)
FIXME_docs.
int Read(uint8_t *data, size_t count, RerrMsg &emsg)
FIXME_docs.
int Tell(RerrMsg &emsg)
FIXME_docs.
static std::unique_ptr< Rw11VirtStream > New(const std::string &url, Rw11Unit *punit, RerrMsg &emsg)
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
~Rw11VirtStream()
Destructor.
bool Flush(RerrMsg &emsg)
FIXME_docs.
bool Eof() const
FIXME_docs.
bool Error() const
FIXME_docs.
bool Seek(int pos, RerrMsg &emsg)
FIXME_docs.
virtual bool Open(const std::string &url, RerrMsg &emsg)
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Rw11Unit * fpUnit
back ref to unit
bool fWProt
write protected
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Declaration of class ReventLoop.