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( TQ_OpenMode m ) {
52 if ( m & IO_ReadOnly ) {
62 kdWarning(7005) <<
"KLimitedIODevice::open only supports IO_ReadOnly!" << endl;
67 virtual void close() {}
68 virtual void flush() {}
71 virtual qint64 size()
const {
return m_length; }
73 virtual Offset size()
const {
return m_length; }
76 virtual TQT_TQIO_LONG tqreadBlock (
char * data, TQT_TQIO_ULONG maxlen )
78 maxlen = TQMIN( maxlen, m_length - at() );
79 return m_dev->readBlock( data, maxlen );
81 virtual TQT_TQIO_LONG tqwriteBlock (
const char *, TQT_TQIO_ULONG ) {
return -1; }
82 virtual int putch(
int ) {
return -1; }
86 if ( tqreadBlock(c, 1) == -1)
91 virtual int ungetch(
int c ) {
return m_dev->ungetch(c); }
92 virtual Offset at()
const {
return m_dev->at() - m_start; }
93 virtual bool at( Offset pos ) {
94 Q_ASSERT( pos <= m_length );
95 pos = TQMIN( pos, m_length );
96 return m_dev->at( m_start + pos );
98 virtual bool atEnd()
const {
return m_dev->atEnd() || m_dev->at() >= m_start + m_length; }
KLimitedIODevice(TQIODevice *dev, int start, int length)
Creates a new KLimitedIODevice.
A readonly device that reads from an underlying device from a given point to another (e...