plptools
Loading...
Searching...
No Matches
drive.cc
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#include "config.h"
22#include "rfsv.h"
23
24#include "drive.h"
25
26#include <cstdint>
27#include <iomanip>
28
29using namespace std;
30
32}
33
35 uint32_t driveAttributes,
36 uint32_t mediaAttributes,
37 uint32_t uid,
38 uint64_t size,
39 uint64_t space,
40 char driveLetter,
41 std::string name)
42: mediaType_(mediaType)
43, driveAttributes_(driveAttributes)
44, mediaAttributes_(mediaAttributes)
45, uid_(uid)
46, size_(size)
47, space_(space)
48, driveLetter_(driveLetter)
49, name_(name) {
50}
51
53 mediaType_ = type;
54}
55
56void Drive::setDriveAttributes(uint32_t attr) {
57 driveAttributes_ = attr;
58}
59
60void Drive::setMediaAttributes(uint32_t mediaAttribute) {
61 mediaAttributes_ = mediaAttribute;
62}
63
64void Drive::setUID(uint32_t uid) {
65 uid_ = uid;
66}
67
68void Drive::setSize(uint32_t sizeLo, uint32_t sizeHi) {
69 size_ = (static_cast<unsigned long long>(sizeHi) << 32) + sizeLo;
70}
71
72void Drive::setSpace(uint32_t spaceLo, uint32_t spaceHi) {
73 space_ = (static_cast<unsigned long long>(spaceHi) << 32) + spaceLo;
74}
75
76void Drive::setName(char drive, const char * const volname) {
77 driveLetter_ = drive;
78 name_ = "";
79 name_ += volname;
80}
81
83 return mediaType_;
84}
85
86uint32_t Drive::getDriveAttributes() const {
87 return driveAttributes_;
88}
89
90uint32_t Drive::getMediaAttributes() const {
91 return mediaAttributes_;
92}
93
94uint32_t Drive::getUID() const {
95 return uid_;
96}
97
98uint64_t Drive::getSize() const {
99 return size_;
100}
101
102uint64_t Drive::getSpace() const {
103 return space_;
104}
105
106string Drive::getName() const {
107 return name_;
108}
109
111 return driveLetter_;
112}
113
114std::string Drive::getPath() const {
115 std::string path;
116 path += driveLetter_;
117 path += ":\\";
118 return path;
119}
uint32_t getDriveAttributes() const
Retrieve the attributes of the drive.
Definition: drive.cc:86
char getDriveLetter() const
Retrieve the drive letter of the drive.
Definition: drive.cc:110
uint64_t space_
Definition: drive.h:196
void setSpace(uint32_t spaceLo, uint32_t spaceHi)
Definition: drive.cc:72
uint32_t getUID() const
Retrieve the UID of the drive.
Definition: drive.cc:94
MediaType getMediaType() const
Retrieve the media type of the drive.
Definition: drive.cc:82
char driveLetter_
Definition: drive.h:197
void setName(char drive, const char *const volname)
Definition: drive.cc:76
void setUID(uint32_t uid)
Definition: drive.cc:64
MediaType mediaType_
Definition: drive.h:191
uint32_t driveAttributes_
Definition: drive.h:192
uint64_t getSpace() const
Retrieve the free capacity on the drive.
Definition: drive.cc:102
uint32_t uid_
Definition: drive.h:194
void setMediaType(MediaType type)
Definition: drive.cc:52
uint64_t getSize() const
Retrieve the total capacity of the drive.
Definition: drive.cc:98
std::string getName() const
Retrieve the volume name of the drive.
Definition: drive.cc:106
uint32_t getMediaAttributes() const
Retrieve the attributes of the media.
Definition: drive.cc:90
std::string getPath() const
Get the file system path given by the current drive.
Definition: drive.cc:114
void setDriveAttributes(uint32_t driveAttribute)
Definition: drive.cc:56
std::string name_
Definition: drive.h:198
uint32_t mediaAttributes_
Definition: drive.h:193
uint64_t size_
Definition: drive.h:195
void setMediaAttributes(uint32_t mediaAttribute)
Definition: drive.cc:60
Drive()
Default constructor.
Definition: drive.cc:31
void setSize(uint32_t sizeLo, uint32_t sizeHi)
Definition: drive.cc:68
MediaType
Definition: drive.h:31
Definition: doctest.h:522