00001 #ifndef CLASSLIB_CPIO_INPUT_STREAM_H 00002 # define CLASSLIB_CPIO_INPUT_STREAM_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "classlib/zip/CPIOConstants.h" 00007 # include "classlib/iotools/FilterInputStream.h" 00008 # include <string> 00009 00010 namespace lat { 00011 //<<<<<< PUBLIC DEFINES >>>>>> 00012 //<<<<<< PUBLIC CONSTANTS >>>>>> 00013 //<<<<<< PUBLIC TYPES >>>>>> 00014 00015 class CPIOMember; 00016 00017 //<<<<<< PUBLIC VARIABLES >>>>>> 00018 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00019 //<<<<<< CLASS DECLARATIONS >>>>>> 00020 00025 class CPIOInputStream : public FilterInputStream, public CPIOConstants 00026 { 00027 public: 00028 CPIOInputStream (InputStream *input); 00029 ~CPIOInputStream (void); 00030 // no copy constructor 00031 // no assignment operator 00032 00033 using FilterInputStream::read; 00034 virtual CPIOMember *nextMember (void); 00035 virtual IOSize available (void); 00036 virtual IOSize read (void *into, IOSize n); 00037 virtual IOSize skip (IOSize n); 00038 virtual void closeMember (void); 00039 00040 virtual void close (void); 00041 virtual void reset (void); 00042 00043 private: 00044 CPIOMember * readPosixHeader (void); 00045 CPIOMember * readSvrHeader (bool check); 00046 00047 bool checkHex (const void *buf, IOSize length); 00048 bool checkOctal (const void *buf, IOSize length); 00049 00050 int m_format; //< Archive format (one of magic values) 00051 CPIOMember *m_current; //< Current member 00052 IOOffset m_remaining; //< Bytes left of current member 00053 unsigned m_checksum; //< Checksum for the file contents. 00054 unsigned m_sum; //< Checksum for data read so far. 00055 bool m_check; //< Flag indicating #m_checksum is valid. 00056 }; 00057 00058 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00059 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>> 00060 00061 } // namespace lat 00062 #endif // CLASSLIB_CPIO_INPUT_STREAM_H