00001 #ifndef CLASSLIB_CPIO_OUTPUT_STREAM_H 00002 # define CLASSLIB_CPIO_OUTPUT_STREAM_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "classlib/zip/CPIOConstants.h" 00007 # include "classlib/iotools/FilterOutputStream.h" 00008 00009 namespace lat { 00010 //<<<<<< PUBLIC DEFINES >>>>>> 00011 //<<<<<< PUBLIC CONSTANTS >>>>>> 00012 //<<<<<< PUBLIC TYPES >>>>>> 00013 00014 class CPIOMember; 00015 class MemoryStorage; 00016 00017 //<<<<<< PUBLIC VARIABLES >>>>>> 00018 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00019 //<<<<<< CLASS DECLARATIONS >>>>>> 00020 00021 // FIXME: this won't work with real tape devices, since we only pretend 00022 // to write up to the record size. we don't actually ever do, we just 00023 // pad up to the right size at the end. 00024 00029 class CPIOOutputStream : public FilterOutputStream, public CPIOConstants 00030 { 00031 public: 00032 CPIOOutputStream (OutputStream *output, int format = ODC_MAGIC); 00033 ~CPIOOutputStream (void); 00034 // no copy constructor 00035 // no assignment operator 00036 00037 using FilterOutputStream::write; 00038 virtual void nextMember (CPIOMember *member, bool autobuffer=false); 00039 virtual IOSize write (const void *from, IOSize n); 00040 virtual void closeMember (void); 00041 virtual void finish (void); 00042 00043 protected: 00044 virtual void writeHeader (void); 00045 00046 private: 00047 void writePosixHeader (void); 00048 void writeSvrHeader (void); 00049 00050 int m_format; //< Archive format (one of magic values) 00051 CPIOMember *m_current; //< Current member we are writing 00052 MemoryStorage *m_buffer; //< Automatic buffer if requested 00053 IOOffset m_remaining; //< Bytes still to come for this member 00054 unsigned m_checksum; //< Checksum of file contents (only for autobuffer) 00055 bool m_finished; //< Indicates when #finished() was done 00056 }; 00057 00058 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00059 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>> 00060 00061 } // namespace lat 00062 #endif // CLASSLIB_CPIO_OUTPUT_STREAM_H