7 Copyright (C) 2009-2010, 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>
38 /// Seeks the input stream to the next packed sibling .cod file and returns
39 /// the packed .cod file size. When all siblings have been read, zero is
42 /// When input stream does not contain the signature for a packed .cod file,
43 /// it's assumed the entire stream is the .cod file.
45 /// \param input stream to read from
47 /// \return size of next packed .cod file, or 0 finished reading .cod files
49 size_t SeekNextCod(std::istream
&input
);
53 /// The CodFileBuilder class is used to assemble multiple .cod files into
54 /// a single packed .cod file using the pkzip file format.
56 class BXEXPORT CodFileBuilder
58 std::string m_module_name
;
60 size_t m_module_count
;
61 unsigned int m_current_module
;
63 std::ostringstream m_directory
;
66 CodFileBuilder(const std::string
&module_name
, size_t module_count
= 1);
71 /// Writes packed .cod file header to the output stream, and appends
72 /// an entry to the central directory. If the module count used to
73 /// create CodFileBuilder is equal to one, the call is ignored.
75 /// Note: it is the caller's responsibility to write the actual
76 /// COD file data after calling this function.
78 /// \param output stream to write to
80 /// \param buffer buffered .cod file data, input to CRC-32 function
82 /// \param module_size total size of .cod file data
84 void WriteNextHeader(std::ostream
&output
, const uint8_t* buffer
,
85 uint32_t module_size
);
88 /// Write the central directory and central directory ending indicator
89 /// to the output stream.
91 /// \param output stream to write to
93 void WriteFooter(std::ostream
&output
);