ScummVM API documentation
u6_lib_n.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_FILES_U6LIB_N_H
23 #define NUVIE_FILES_U6LIB_N_H
24 
25 #include "common/str.h"
26 #include "common/stream.h"
27 
28 namespace Ultima {
29 namespace Nuvie {
30 
31 class NuvieIO;
32 
33 struct U6LibItem {
34  uint32 offset;
35  uint8 flag;
36  uint32 uncomp_size;
37  uint32 size;
38  Common::String *name;
39  unsigned char *data; // for writing or cache
40 };
41 
42 class U6Lib_n {
43  uint32 filesize; // total size of file
44  uint8 game_type; // there are three types of lib files.
45  uint8 lib_size; // measured in bytes either 2 or 4
46  uint32 num_offsets; // number of items, size of lists
47  U6LibItem *items;
48  NuvieIO *data;
49  bool del_data;
50 
51 public:
52  U6Lib_n();
53  ~U6Lib_n();
54 
55  bool open(const Common::Path &filename, uint8 size, uint8 type = NUVIE_GAME_U6);
56  bool open(NuvieIO *new_data, uint8 size, uint8 type = NUVIE_GAME_U6);
57  void close();
58  bool create(const Common::Path &filename, uint8 size, uint8 type = NUVIE_GAME_U6);
59  uint8 get_game_type() {
60  return game_type;
61  }
62 
63  unsigned char *get_item(uint32 item_number, unsigned char *buf = nullptr); // read
64  void set_item_data(uint32 item_number, unsigned char *src, uint32 src_len);
65 
66  uint32 get_num_items();
67  uint32 get_item_size(uint32 item_number);
68  uint32 get_item_offset(uint32 item_number);
69  const char *get_item_name(uint32 item_number);
70  bool is_compressed(uint32 item_number);
71 
72  void add_item(uint32 offset32, const char *name = nullptr);
73  void write_item(uint32 item_number);
74  void write_items();
75 
76  void load_index(Common::ReadStream *index_f);
77  void write_index();
78  void write_header();
79 
80  void calc_item_offsets();
81 
82 protected:
83  void parse_lib();
84  void calculate_item_sizes();
85  uint32 calculate_item_uncomp_size(U6LibItem *item);
86  uint32 calculate_num_offsets(bool skip4);
87 };
88 
89 #if 0
90 class U6ConverseLib: U6Lib_n {
91 private:
92  uint32 zero_offset_count;
93  Common::String *conversefile;
94 };
95 #endif
96 } // End of namespace Nuvie
97 } // End of namespace Ultima
98 
99 
100 #endif
Definition: str.h:59
Definition: u6_lib_n.h:33
Definition: path.h:52
Definition: detection.h:27
Definition: u6_lib_n.h:42
Definition: stream.h:385
Definition: nuvie_io.h:32