openMSX
DiskManipulator.hh
Go to the documentation of this file.
1#ifndef FILEMANIPULATOR_HH
2#define FILEMANIPULATOR_HH
3
4#include "Command.hh"
5#include <string_view>
6#include <vector>
7#include <memory>
8
9namespace openmsx {
10
11class CommandController;
12class DiskContainer;
13class SectorAccessibleDisk;
14class DiskPartition;
15class MSXtar;
16class Reactor;
17
18class DiskManipulator final : public Command
19{
20public:
21 explicit DiskManipulator(CommandController& commandController,
22 Reactor& reactor);
24
25 void registerDrive(DiskContainer& drive, std::string_view prefix);
26 void unregisterDrive(DiskContainer& drive);
27
28private:
29 static constexpr unsigned MAX_PARTITIONS = 31;
30 struct DriveSettings
31 {
32 DiskContainer* drive;
33 std::string driveName; // includes machine prefix
34 std::string workingDir[MAX_PARTITIONS + 1];
36 unsigned partition;
37 };
38 using Drives = std::vector<DriveSettings>;
39 Drives drives; // unordered
40
41 // Command interface
42 void execute(std::span<const TclObject> tokens, TclObject& result) override;
43 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
44 void tabCompletion(std::vector<std::string>& tokens) const override;
45
46 [[nodiscard]] std::string getMachinePrefix() const;
47 [[nodiscard]] Drives::iterator findDriveSettings(DiskContainer& drive);
48 [[nodiscard]] Drives::iterator findDriveSettings(std::string_view driveName);
49 [[nodiscard]] DriveSettings& getDriveSettings(std::string_view diskname);
50 [[nodiscard]] static DiskPartition getPartition(
51 const DriveSettings& driveData);
52 [[nodiscard]] static MSXtar getMSXtar(SectorAccessibleDisk& disk,
53 DriveSettings& driveData);
54
55 static void create(std::span<const TclObject> tokens);
56 void savedsk(const DriveSettings& driveData, std::string filename);
57 void format(DriveSettings& driveData, bool dos1);
58 std::string chdir(DriveSettings& driveData, std::string_view filename);
59 void mkdir(DriveSettings& driveData, std::string_view filename);
60 [[nodiscard]] std::string dir(DriveSettings& driveData);
61 std::string import(DriveSettings& driveData,
62 std::span<const TclObject> lists);
63 void exprt(DriveSettings& driveData, std::string_view dirname,
64 std::span<const TclObject> lists);
65
66 Reactor& reactor;
67};
68
69} // namespace openmsx
70
71#endif
void unregisterDrive(DiskContainer &drive)
DiskManipulator(CommandController &commandController, Reactor &reactor)
void registerDrive(DiskContainer &drive, std::string_view prefix)
Contains the main loop of openMSX.
Definition: Reactor.hh:68
void partition(SectorAccessibleDisk &disk, std::span< const unsigned > sizes)
Write a partition table to the given disk and format each partition.
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr const char *const filename