aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plpdirent.h
blob: f29cc742d19c91d93d4d2578f02d474b940655b1 (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
#ifndef _PLP_DIRENT_H_
#define _PLP_DIRENT_H_

#include <string>
#include <psitime.h>
#include <rfsv.h>

/**
 * A class, representing a directory entry of the Psion.
 * Objects of this type are used by @ref rfsv::readdir and
 * @ref rfsv::dir for returning the entries of a directory.
 */
class PlpDirent {
	friend class rfsv32;
	friend class rfsv16;

public:
	/**
	 * Default constructor
	 */
	PlpDirent() : size(0), attr(0), name(""), time(0L), attrstr("") { };

	/**
	 * A copy constructor.
	 * Mainly used by STL container classes.
	 *
	 * @param d The object to be used as initializer.
	 */
	PlpDirent(const PlpDirent &d);

	/**
	 * Default destructor.
	 */
	~PlpDirent() {};

	/**
	 * Retrieves the file size of a directory entry.
	 *
	 * @returns The file size in bytes.
	 */
	long getSize();

	/**
	 * Retrieves the file attributes of a directory entry.
	 *
	 * @returns The generic attributes ( @ref rfsv:file_attribs ).
	 */
	long 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.
	 */
	long getUID(int uididx);

	/**
	 * 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 opreator
	 * 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:
	long    size;
	long    attr;
	long    uid[3];
	PsiTime time;
	string  attrstr;
	string  name;
};
#endif