19 #ifndef klimitediodevice_h
20 #define klimitediodevice_h
23 #include <tqiodevice.h>
42 : m_dev( dev ), m_start( start ), m_length( length )
50 virtual bool open(
int m ) {
52 if ( m & IO_ReadOnly ) {
62 kdWarning(7005) <<
"KLimitedIODevice::open only supports IO_ReadOnly!" << endl;
67 virtual void close() {}
68 virtual void flush() {}
70 virtual Offset size()
const {
return m_length; }
72 virtual TQ_LONG readBlock (
char * data, TQ_ULONG maxlen )
74 maxlen = TQMIN( maxlen, m_length - at() );
75 return m_dev->readBlock( data, maxlen );
77 virtual TQ_LONG writeBlock (
const char *, TQ_ULONG ) {
return -1; }
78 virtual int putch(
int ) {
return -1; }
82 if ( readBlock(c, 1) == -1)
87 virtual int ungetch(
int c ) {
return m_dev->ungetch(c); }
88 virtual Offset at()
const {
return m_dev->at() - m_start; }
89 virtual bool at( Offset pos ) {
90 Q_ASSERT( pos <= m_length );
91 pos = TQMIN( pos, m_length );
92 return m_dev->at( m_start + pos );
94 virtual bool atEnd()
const {
return m_dev->atEnd() || m_dev->at() >= m_start + m_length; }
A readonly device that reads from an underlying device from a given point to another (e....
KLimitedIODevice(TQIODevice *dev, int start, int length)
Creates a new KLimitedIODevice.