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 "ultima/shared/std/containers.h"
26 #include "ultima/shared/std/string.h"
27 #include "common/stream.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 using Std::string;
33 //using Std::vector;
34 
35 class NuvieIO;
36 
37 struct U6LibItem {
38  uint32 offset;
39  uint8 flag;
40  uint32 uncomp_size;
41  uint32 size;
42  string *name;
43  unsigned char *data; // for writing or cache
44 };
45 
46 class U6Lib_n {
47  uint32 filesize; // total size of file
48  uint8 game_type; // there are three types of lib files.
49  uint8 lib_size; // measured in bytes either 2 or 4
50  uint32 num_offsets; // number of items, size of lists
51  U6LibItem *items;
52  NuvieIO *data;
53  bool del_data;
54 
55 public:
56  U6Lib_n();
57  ~U6Lib_n();
58 
59  bool open(const Common::Path &filename, uint8 size, uint8 type = NUVIE_GAME_U6);
60  bool open(NuvieIO *new_data, uint8 size, uint8 type = NUVIE_GAME_U6);
61  void close();
62  bool create(const Common::Path &filename, uint8 size, uint8 type = NUVIE_GAME_U6);
63  uint8 get_game_type() {
64  return game_type;
65  }
66 
67  unsigned char *get_item(uint32 item_number, unsigned char *buf = nullptr); // read
68  void set_item_data(uint32 item_number, unsigned char *src, uint32 src_len);
69 
70  uint32 get_num_items();
71  uint32 get_item_size(uint32 item_number);
72  uint32 get_item_offset(uint32 item_number);
73  const char *get_item_name(uint32 item_number);
74  bool is_compressed(uint32 item_number);
75 
76  void add_item(uint32 offset32, const char *name = nullptr);
77  void write_item(uint32 item_number);
78  void write_items();
79 
80  void load_index(Common::ReadStream *index_f);
81  void write_index();
82  void write_header();
83 
84  void calc_item_offsets();
85 
86 protected:
87  void parse_lib();
88  void calculate_item_sizes();
89  uint32 calculate_item_uncomp_size(U6LibItem *item);
90  uint32 calculate_num_offsets(bool skip4);
91 };
92 
93 #if 0
94 class U6ConverseLib: U6Lib_n {
95 private:
96  uint32 zero_offset_count;
97  string *conversefile;
98 };
99 #endif
100 } // End of namespace Nuvie
101 } // End of namespace Ultima
102 
103 
104 #endif
Definition: u6_lib_n.h:37
Definition: path.h:52
Definition: detection.h:27
Definition: u6_lib_n.h:46
Definition: stream.h:385
Definition: nuvie_io.h:32