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 <array>
6#include <memory>
7#include <string_view>
8#include <vector>
9
10namespace openmsx {
11
12class CommandController;
13class DiskContainer;
14class SectorAccessibleDisk;
15class DiskPartition;
16class MSXtar;
17class Reactor;
18class MsxChar2Unicode;
19enum class MSXBootSectorType;
20
21class DiskManipulator final : public Command
22{
23public:
24 explicit DiskManipulator(CommandController& commandController,
25 Reactor& reactor);
27
28 void registerDrive(DiskContainer& drive, std::string_view prefix);
29 void unregisterDrive(DiskContainer& drive);
30
31private:
32 struct DriveSettings
33 {
34 std::string getWorkingDir(unsigned p);
35 void setWorkingDir(unsigned p, std::string_view dir);
36
37 DiskContainer* drive;
38 std::string driveName; // includes machine prefix
40 unsigned partition;
41 private:
42 std::vector<std::string> workingDir;
43 };
44 using Drives = std::vector<DriveSettings>;
45 Drives drives; // unordered
46
47 // Command interface
48 void execute(std::span<const TclObject> tokens, TclObject& result) override;
49 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
50 void tabCompletion(std::vector<std::string>& tokens) const override;
51
52 [[nodiscard]] std::string getMachinePrefix() const;
53 [[nodiscard]] const MsxChar2Unicode& getMsxChar2Unicode() const;
54 [[nodiscard]] Drives::iterator findDriveSettings(DiskContainer& drive);
55 [[nodiscard]] Drives::iterator findDriveSettings(std::string_view driveName);
56 [[nodiscard]] DriveSettings& getDriveSettings(std::string_view diskName);
57 [[nodiscard]] static DiskPartition getPartition(
58 const DriveSettings& driveData);
59 [[nodiscard]] MSXtar getMSXtar(SectorAccessibleDisk& disk,
60 DriveSettings& driveData);
61
62 void create(std::span<const TclObject> tokens);
63 void partition(std::span<const TclObject> tokens);
64 void savedsk(const DriveSettings& driveData, std::string filename);
65 void format(std::span<const TclObject> tokens);
66 std::string chdir(DriveSettings& driveData, std::string_view filename);
67 void mkdir(DriveSettings& driveData, std::string_view filename);
68 [[nodiscard]] std::string dir(DriveSettings& driveData);
69 std::string import(DriveSettings& driveData,
70 std::span<const TclObject> lists);
71 void exprt(DriveSettings& driveData, std::string_view dirname,
72 std::span<const TclObject> lists);
73
74 Reactor& reactor;
75};
76
77} // namespace openmsx
78
79#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
unsigned partition(SectorAccessibleDisk &disk, std::span< const unsigned > sizes, MSXBootSectorType bootType)
Write a partition table to the given disk and format each partition.
This file implemented 3 utility functions:
Definition: Autofire.cc:9