17[[nodiscard]]
static TclObject initialFilePoolSettingValue()
24 "-types",
"system_rom"),
26 "-types",
"rom disk tape"));
32 : core(FileOperations::getUserDataDir() +
"/.filecache",
34 [&](std::string_view message,
float fraction) { reportProgress(message, fraction); })
36 controller,
"__filepool",
37 "This is an internal setting. Don't change this directly, "
38 "instead use the 'filepool' command.",
39 initialFilePoolSettingValue().
getString())
41 , sha1SumCommand(controller)
43 filePoolSetting.attach(*
this);
44 reactor.getEventDistributor().registerEventListener(
EventType::QUIT, *
this);
50 filePoolSetting.
detach(*
this);
55 return core.
getFile(fileType, sha1sum);
77 for (
auto i :
xrange(list.getListLength(interp))) {
79 if (elem ==
"system_rom") {
81 }
else if (elem ==
"rom") {
83 }
else if (elem ==
"disk") {
85 }
else if (elem ==
"tape") {
88 throw CommandException(
"Unknown type: ", elem);
102 bool hasPath =
false;
108 "Expected a list with an even number "
109 "of elements, but got ", line.
getString());
111 for (
unsigned j = 0; j < numItems; j += 2) {
114 if (name ==
"-path") {
117 }
else if (name ==
"-types") {
118 dir.
types = parseTypes(interp, value);
125 "Missing -path item: ", line.
getString());
129 "Missing -types item: ", line.
getString());
131 result.push_back(std::move(dir));
135 "Error while parsing '__filepool' setting", e.getMessage());
143 (void)getDirectories();
146void FilePool::reportProgress(std::string_view message,
float fraction)
148 if (quit) core.
abort();
153bool FilePool::signalEvent(
const Event& event)
164FilePool::Sha1SumCommand::Sha1SumCommand(
165 CommandController& commandController_)
166 : Command(commandController_,
"sha1sum")
170void FilePool::Sha1SumCommand::execute(std::span<const TclObject> tokens, TclObject& result)
172 checkNumArgs(tokens, 2,
"filename");
174 auto& filePool =
OUTER(FilePool, sha1SumCommand);
175 result = filePool.getSha1Sum(file).toString();
178std::string FilePool::Sha1SumCommand::help(std::span<const TclObject> )
const
180 return "Calculate sha1 value for the given file. If the file is "
181 "(g)zipped the sha1 is calculated on the unzipped version.";
184void FilePool::Sha1SumCommand::tabCompletion(std::vector<std::string>& tokens)
const
void printProgress(std::string_view message, float fraction)
void printWarning(std::string_view message)
void repaint()
Redraw the display.
void unregisterEventListener(EventType type, EventListener &listener)
Unregisters a previously registered event listener.
Sha1Sum getSha1Sum(File &file)
Calculate sha1sum for the given File object.
File getFile(FileType fileType, const Sha1Sum &sha1sum)
Search file with the given sha1sum.
void abort()
This is only meaningful to call from within the 'reportProgress' callback (constructor parameter).
std::vector< Dir > Directories
FilePool(CommandController &controller, Reactor &reactor)
FilePoolCore::Directories getDirectories() const
Sha1Sum getSha1Sum(File &file)
Calculate sha1sum for the given File object.
File getFile(FileType fileType, const Sha1Sum &sha1sum)
Search file with the given sha1sum.
Contains the main loop of openMSX.
EventDistributor & getEventDistributor()
Interpreter & getInterpreter() const
const TclObject & getValue() const final
Gets the current value of this setting as a TclObject.
This class represents the result of a sha1 calculation (a 160-bit value).
void detach(Observer< T > &observer)
unsigned getListLength(Interpreter &interp) const
TclObject getListIndex(Interpreter &interp, unsigned index) const
void addListElement(const T &t)
zstring_view getString() const
string expandTilde(string path)
Expand the '~' character to the users home directory.
This file implemented 3 utility functions:
const FileContext & systemFileContext()
EventType getType(const Event &event)
const FileContext & userFileContext()
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
TclObject makeTclDict(Args &&... args)
#define OUTER(type, member)
TemporaryString tmpStrCat(Ts &&... ts)
constexpr auto xrange(T e)