aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sisfile.h
blob: 7a9d6da42c44e73830dc5b0ee6a7a57f57c968e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* -*-c++-*-
 * $Id$
 *
 * This file is part of plptools.
 *
 *  Copyright (C) 2002 Daniel Brahneborg <basic.chello@se>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _SISFILE_H
#define _SISFILE_H

#include <sistypes.h>
#include <sisfileheader.h>
#include <siscomponentrecord.h>

class SISLangRecord;
class SISFileRecord;
class SISReqRecord;

/**
 * The top level container of a SIS file.
 * Based on documentation by Alexander Thoukydides <alex@thouky.co.uk>.
 */
class SISFile
{
public:

	SISFile();

	virtual ~SISFile();

	/**
	 * Compare uid and version number of this file, with another.
	 *
	 * @see SISFileHeader::compareApp()
	 */
	SisRC compareApp(SISFile* other);

	/**
	 * Populate the fields.
	 *
	 * @param buf The buffer to read from.
	 * @param len The length of the buffer.
	 */
	SisRC fillFrom(uint8_t* buf, off_t len);

	/**
	 * Return the currently selected installation language.
	 */
	int getLanguage();

	/**
	 * Find a language entry, based on the sequence number in the SISLangRecord
	 * part of the file.
	 */
	LangTableEntry* getLanguage(int i);

	/**
	 * Get the name of this component, in the selected language.
	 */
	uint8_t* getName();

	/**
	 * Get the number of bytes that should be copied to the residual sis
	 * file on the psion.
	 */
	uint32_t getResidualEnd()
		{
		return m_end;
		}

	void ownBuffer()
		{
		m_ownBuffer = true;
		}

	/**
	 * Is this the same application?
	 */
	bool sameApp(SISFile* other);

	/**
	 * Set the installed drive.
	 */
	void setDrive(char drive);

	/**
	 * Set the number of installed files.
	 */
	void setFiles(int nFiles);

	/**
	 * Set the selected installation language.
	 */
	void setLanguage(int lang);

	SISFileHeader m_header;
	SISLangRecord* m_langRecords;
	SISFileRecord* m_fileRecords;
	SISReqRecord* m_reqRecords;

private:

	SISComponentNameRecord m_componentRecord;

	bool m_ownBuffer;

	uint8_t* m_buf;

	uint32_t m_end;

	void updateEnd(uint32_t pos);

};

#endif