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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
/*-*-c++-*-
* $Id$
*
* This file is part of plptools.
*
* Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
*
* 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 _PLPDIRENT_H_
#define _PLPDIRENT_H_
#include <string>
#include <psitime.h>
#include <rfsv.h>
/**
* A class, representing the UIDs of a file on the Psion.
* Every File on the Psion has a unique UID for determining
* the application-mapping. This class stores these UIDs.
* An object of this class is contained in every @ref PlpDirent
* object.
*
* @author Fritz Elfert <felfert@to.com>
*/
class PlpUID
{
friend inline bool operator<(const PlpUID &u1, const PlpUID &u2);
public:
/**
* Default constructor.
*/
PlpUID();
/**
* Constructor.
* Create an instance, presetting all thre uid values.
*/
PlpUID(const u_int32_t u1, const u_int32_t u2, const u_int32_t u3);
/**
* Retrieve a UID value.
*
* @param idx The index of the desired UID. Range must be (0..2),
* otherwise an assertion is triggered.
*/
u_int32_t operator[](int idx);
private:
long uid[3];
};
inline bool operator<(const PlpUID &u1, const PlpUID &u2) {
return (memcmp(u1.uid, u2.uid, sizeof(u1.uid)) < 0);
}
/**
* A class, representing a directory entry of the Psion.
* Objects of this type are used by @ref rfsv::readdir ,
* @ref rfsv::dir and @ref rfsv::fgeteattr for returning
* the entries of a directory.
*
* @author Fritz Elfert <felfert@to.com>
*/
class PlpDirent {
friend class rfsv32;
friend class rfsv16;
public:
/**
* Default constructor
*/
PlpDirent();
/**
* A copy constructor.
* Mainly used by STL container classes.
*
* @param d The object to be used as initializer.
*/
PlpDirent(const PlpDirent &d);
/**
* Initializing Constructor
*/
PlpDirent(const u_int32_t size, const u_int32_t attr, const u_int32_t tHi,
const u_int32_t tLo, const char * const name);
/**
* Default destructor.
*/
~PlpDirent() {};
/**
* Retrieves the file size of a directory entry.
*
* @returns The file size in bytes.
*/
u_int32_t getSize();
/**
* Retrieves the file attributes of a directory entry.
*
* @returns The generic attributes ( @ref rfsv:file_attribs ).
*/
u_int32_t getAttr();
/**
* Retrieves the UIDs of a directory entry.
* This method returns always 0 with a Series3.
*
* @param uididx The index of the UID to retrieve (0 .. 2).
*
* @returns The selected UID or 0 if the index is out of range.
*/
u_int32_t getUID(int uididx);
/**
* Retrieves the @ref PlpUID object of a directory entry.
*
* @returns The PlpUID object.
*/
PlpUID &getUID();
/**
* Retrieve the file name of a directory entry.
*
* @returns The name of the file.
*/
const char *getName();
/**
* Retrieve the modification time of a directory entry.
*
* @returns A @ref PsiTime object, representing the time.
*/
PsiTime getPsiTime();
/**
* Set the file name of a directory entry.
* This is currently used in plpbackup only for
* changing the name to the full path. It does NOT
* change the name of the corresponding file on
* the Psion.
*
* @param str The new name of the file.
*/
void setName(const char *str);
/**
* Assignment operator
* Mainly used by STL container classes.
*
* @param e The new value to assign.
*
* @returns The modified object.
*/
PlpDirent &operator=(const PlpDirent &e);
/**
* Prints the object contents.
* The output is in human readable similar to the
* output of a "ls" command.
*/
friend ostream &operator<<(ostream &o, const PlpDirent &e);
private:
u_int32_t size;
u_int32_t attr;
PlpUID UID;
PsiTime time;
string attrstr;
string name;
};
/**
* A class representing information about
* a Disk drive on the psion. An Object of this type
* is used by @ref rfsv::devinfo for returning the
* information of the probed drive.
*
* @author Fritz Elfert <felfert@to.com>
*/
class PlpDrive {
friend rfsv32;
friend rfsv16;
public:
/**
* Default constructor.
*/
PlpDrive();
/**
* Copy constructor
*/
PlpDrive(const PlpDrive &other);
/**
* Retrieve the media type of the drive.
*
* @returns The media type of the probed drive.
* <pre>
* Media types are encoded by a number
* in the range 0 .. 8 with the following
* meaning:
*
* 0 = Not present
* 1 = Unknown
* 2 = Floppy
* 3 = Disk
* 4 = CD-ROM
* 5 = RAM
* 6 = Flash Disk
* 7 = ROM
* 8 = Remote
* </pre>
*/
u_int32_t getMediaType();
/**
* Retrieve the media type of the drive.
* Just like the above function, but returns
* the media type as human readable string.
*
* @param ret The string is returned here.
*/
void getMediaType(string &ret);
/**
* Retrieve the attributes of the drive.
*
* @returns The attributes of the probed drive.
* <pre>
* Drive attributes are encoded by a number
* in the range 0 .. 63. The bits have the
* the following meaning:
*
* bit 0 = local
* bit 1 = ROM
* bit 2 = redirected
* bit 3 = substituted
* bit 4 = internal
* bit 5 = removable
* </pre>
*/
u_int32_t getDriveAttribute();
/**
* Retrieve the attributes of the drive.
* Just like the above function, but returns
* the attributes as human readable string.
*
* @param ret The string is returned here.
*/
void getDriveAttribute(string &ret);
/**
* Retrieve the attributes of the media.
*
* @returns The attributes of the probed media.
* <pre>
* Media attributes are encoded by a number
* in the range 0 .. 15. The bits have the
* following meaning:
*
* bit 0 = variable size
* bit 1 = dual density
* bit 2 = formattable
* bit 3 = write protected
* </pre>
*/
u_int32_t getMediaAttribute();
/**
* Retrieve the attributes of the media.
* Just like the above function, but returns
* the attributes as human readable string.
*
* @param ret The string is returned here.
*/
void getMediaAttribute(string &ret);
/**
* Retrieve the UID of the drive.
* Each drive, except the ROM drive on a Psion has
* a unique ID which can be retrieved here.
*
* @returns The UID of the probed drive.
*/
u_int32_t getUID();
/**
* Retrieve the total capacity of the drive.
*
* @returns The capacity of the probed drive in bytes.
*/
u_int64_t getSize();
/**
* Retrieve the free capacity on the drive.
*
* @returns The free space on the probed drive in bytes.
*/
u_int64_t getSpace();
/**
* Retrieve the volume name of the drive.
*
* returns The volume name of the drive.
*/
string getName();
/**
* Retrieve the drive letter of the drive.
*
* returns The letter of the probed drive.
*/
char getDrivechar();
private:
void setMediaType(u_int32_t type);
void setDriveAttribute(u_int32_t attr);
void setMediaAttribute(u_int32_t attr);
void setUID(u_int32_t uid);
void setSize(u_int32_t sizeLo, u_int32_t sizeHi);
void setSpace(u_int32_t spaceLo, u_int32_t spaceHi);
void setName(char drive, const char * const volname);
u_int32_t mediatype;
u_int32_t driveattr;
u_int32_t mediaattr;
u_int32_t uid;
u_int64_t size;
u_int64_t space;
char drivechar;
string name;
};
#endif
/*
* Local variables:
* c-basic-offset: 4
* End:
*/
|