plptools
Loading...
Searching...
No Matches
plpdirent.h
Go to the documentation of this file.
1/*
2 * This file is part of plptools.
3 *
4 * Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
5 * Copyright (c) 2026 Jason Morley <hello@jbmorley.co.uk>
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 2 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 along
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 *
20 */
21#pragma once
22
23#include <cstdint>
24#include <iostream>
25#include <string>
26#include <cstring>
27
28#include "psitime.h"
29#include "rfsv.h"
30
40class PlpUID
41{
42 friend inline bool operator<(const PlpUID &u1, const PlpUID &u2);
43public:
47 PlpUID();
48
53 PlpUID(const uint32_t u1, const uint32_t u2, const uint32_t u3);
54
61 uint32_t operator[](int idx);
62
63private:
64 long uid[3];
65};
66
67inline bool operator<(const PlpUID &u1, const PlpUID &u2) {
68 return (memcmp(u1.uid, u2.uid, sizeof(u1.uid)) < 0);
69}
70
79class PlpDirent {
80 friend class RFSV32;
81 friend class RFSV16;
82
83public:
87 PlpDirent();
88
95 PlpDirent(const PlpDirent &e) = default;
96
100 PlpDirent(const uint32_t size,
101 const uint32_t attr,
102 const uint32_t tHi,
103 const uint32_t tLo,
104 const std::string &dirname,
105 const char *const name);
106
111
117 uint32_t getSize() const;
118
124 uint32_t getAttr() const;
125
131 bool isDirectory() const;
132
141 uint32_t getUID(int uididx);
142
148 PlpUID &getUID();
149
150 std::string getPath() const;
151
157 const char *getName() const;
158
165
174 void setName(const char *str);
175
184 PlpDirent &operator=(const PlpDirent &e) = default;
185
191 friend std::ostream &operator<<(std::ostream &o, const PlpDirent &e);
192
193private:
194 uint32_t size;
195 uint32_t attr;
198 std::string attrstr;
199 std::string dirname_;
200 std::string name;
201};
A class, representing a directory entry of the Psion.
Definition: plpdirent.h:79
PlpUID & getUID()
Retrieves the PlpUID object of a directory entry.
Definition: plpdirent.cc:89
uint32_t getAttr() const
Retrieves the file attributes of a directory entry.
Definition: plpdirent.cc:75
std::string dirname_
Definition: plpdirent.h:199
~PlpDirent()
Default destructor.
Definition: plpdirent.h:110
std::string attrstr
Definition: plpdirent.h:198
std::string getPath() const
Definition: plpdirent.cc:93
PlpDirent & operator=(const PlpDirent &e)=default
Assignment operator Mainly used by STL container classes.
PsiTime time
Definition: plpdirent.h:197
const char * getName() const
Retrieve the file name of a directory entry.
Definition: plpdirent.cc:102
std::string name
Definition: plpdirent.h:200
PlpDirent()
Default constructor.
Definition: plpdirent.cc:46
bool isDirectory() const
Determine if the directory entry represents a directory.
Definition: plpdirent.cc:79
PlpDirent(const PlpDirent &e)=default
A copy constructor.
friend std::ostream & operator<<(std::ostream &o, const PlpDirent &e)
Prints the object contents.
Definition: plpdirent.cc:114
PlpUID UID
Definition: plpdirent.h:196
void setName(const char *str)
Set the file name of a directory entry.
Definition: plpdirent.cc:110
uint32_t attr
Definition: plpdirent.h:195
PsiTime getPsiTime()
Retrieve the modification time of a directory entry.
Definition: plpdirent.cc:106
uint32_t size
Definition: plpdirent.h:194
uint32_t getSize() const
Retrieves the file size of a directory entry.
Definition: plpdirent.cc:71
A class, representing the UIDs of a file on the Psion.
Definition: plpdirent.h:41
friend bool operator<(const PlpUID &u1, const PlpUID &u2)
Definition: plpdirent.h:67
long uid[3]
Definition: plpdirent.h:64
PlpUID()
Default constructor.
Definition: plpdirent.cc:33
uint32_t operator[](int idx)
Retrieve a UID value.
Definition: plpdirent.cc:41
Psion time related utility class.
Definition: psitime.h:124
This is the implementation of the RFSV protocol for Psion series 3 (SIBO) variant.
Definition: rfsv16.h:35
This is the implementation of the RFSV protocol for Psion series 5 (EPOC) variant.
Definition: rfsv32.h:37
static char * dirname(const char *dir)
Definition: fuse.c:171
bool operator<(const PlpUID &u1, const PlpUID &u2)
Definition: plpdirent.h:67