7 Copyright (C) 2009, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_COD_H__
23 #define __BARRY_COD_H__
27 #include <sys/types.h>
37 /// Seeks the input stream to the next packed sibling .cod file and returns
38 /// the packed .cod file size. When all siblings have been read, zero is
41 /// When input stream does not contain the signature for a packed .cod file,
42 /// it's assumed the entire stream is the .cod file.
44 /// \param input stream to read from
46 /// \return size of next packed .cod file, or 0 finished reading .cod files
48 size_t SeekNextCod(std::istream
&input
);
52 /// The CodFileBuilder class is used to assemble multiple .cod files into
53 /// a single packed .cod file using the pkzip file format.
55 class BXEXPORT CodFileBuilder
57 std::string m_module_name
;
59 size_t m_module_count
;
60 unsigned int m_current_module
;
62 std::ostringstream m_directory
;
65 CodFileBuilder(const std::string
&module_name
, size_t module_count
= 1);
70 /// Writes packed .cod file header to the output stream, and appends
71 /// an entry to the central directory. If the module count used to
72 /// create CodFileBuilder is equal to one, the call is ignored.
74 /// Note: it is the caller's responsibility to write the actual
75 /// COD file data after calling this function.
77 /// \param output stream to write to
79 /// \param buffer buffered .cod file data, input to CRC-32 function
81 /// \param module_size total size of .cod file data
83 void WriteNextHeader(std::ostream
&output
, const uint8_t* buffer
,
84 uint32_t module_size
);
87 /// Write the central directory and central directory ending indicator
88 /// to the output stream.
90 /// \param output stream to write to
92 void WriteFooter(std::ostream
&output
);