libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
OgcFileSystemDriver.h
1/****************************************************************************
2 * Platform Abstraction Layer (OGC driver)
3 * Daryl Borth 2026
4 * OgcFileSystemDriver.h
5 *
6 * Shared enumeration/mount/poll implementation for the GameCube and Wii
7 * FileSystemDrivers. The two platforms differ only in:
8 * - which hot-pluggable FAT-formatted slots physically exist (SD Gecko
9 * A/B/port2/GC Loader on GameCube; SD + up to 3 USB MSD on Wii), and
10 * - how DVD access is wired up (GX DI on GameCube vs. the Wii's
11 * IOS-backed DI).
12 *
13 * DVD is deliberately NEVER probed in pollStorageDevices() - real disc
14 * hardware access only belongs to a genuine user-initiated mount attempt.
15 ***************************************************************************/
16#pragma once
17#include "../FileSystemDriver.h"
18#include "OgcSmbDriver.h"
19#include <ogc/disc_io.h>
20
25{
27 DISC_INTERFACE * (*getDisc)();
28 const char * mountName;
29 const char * prefix;
30 const char * displayName;
31 const char * notFoundMessage;
32 bool removable;
34 bool pollable;
35};
36
40{
41 public:
42 void shutdown() override;
43
44 int enumerateStorageDevices(StorageDevice outDevices[MAX_STORAGE_DEVICES]) override;
45 MountResult mountStorageDevice(int deviceId) override;
46 const char * mountResultMessage(int deviceId, MountResult result) override;
47 void invalidateStorageDevice(int deviceId) override;
48 void pollStorageDevices(int removedIds[MAX_STORAGE_DEVICES], int & outRemovedCount, bool & deviceListChanged) override;
49 bool hasRemovableStorageDevices() const override { return true; }
50 bool isDevicePresent(int deviceId) const override;
51
52 const char * getDevicePrefix(int device) const override;
53 const char * getMountPath(int device) const override;
54
55 SmbDriver * getSmb() override { return &smbDriver; }
56
57 protected:
59 const OgcFatSlotDescriptor * fatSlots = nullptr;
61 int fatSlotCount = 0;
63 DISC_INTERFACE * dvdDisc = nullptr;
65 const char * unsupportedFormatMessage = "Unsupported format.";
66
71
74 virtual void shutdownPlatform() {}
75
81 virtual bool pollPlatformExtra() { return false; }
82
87 virtual void prepareMount(int deviceId) {}
88
90 MountResult mountFAT(int deviceId);
94 MountResult attemptFatMount(int deviceId);
95
97 const OgcFatSlotDescriptor * findFatSlot(int deviceId) const;
98
99 bool isMounted[MAX_STORAGE_DEVICES] = { false };
100 bool unmountRequired[MAX_STORAGE_DEVICES] = { false };
101 bool isPresentCache[MAX_STORAGE_DEVICES] = { false };
102 bool mountFailed[MAX_STORAGE_DEVICES] = { false };
103 bool labelFetched[MAX_STORAGE_DEVICES] = { false };
104 char volumeLabel[MAX_STORAGE_DEVICES][16] = { { 0 } };
105
108};
Storage device enumeration/mount/poll backend for the SD/USB/DVD file browser.
Shared GameCube/Wii FileSystemDriver base: FAT slot enumeration, mounting and polling.
bool isMounted[MAX_STORAGE_DEVICES]
A filesystem is currently mounted for this device.
MountResult attemptFatMount(int deviceId)
Single mountFAT() attempt that also records the outcome in mountFailed.
bool isDevicePresent(int deviceId) const override
Lightweight, cached hardware-presence check for a single device - does NOT mount and does no invasive...
MountResult mountFAT(int deviceId)
Mounts the FAT filesystem on a slot with fatMountSimple(), unmounting first if unmountRequired is set...
void pollStorageDevices(int removedIds[MAX_STORAGE_DEVICES], int &outRemovedCount, bool &deviceListChanged) override
Called once per device-checking thread cycle.
bool unmountRequired[MAX_STORAGE_DEVICES]
A stale mount must be torn down before the next mount attempt.
const OgcFatSlotDescriptor * fatSlots
Table of FAT slots this platform supports; set by the concrete driver.
char volumeLabel[MAX_STORAGE_DEVICES][16]
Volume label cached for each device.
void initFatSlotsAndAutoMount()
Runs the shared boot-time pass: probe every pollable fatSlots[] entry once for isPresentCache,...
bool hasRemovableStorageDevices() const override
Whether the device-checking thread should run on this platform.
const char * unsupportedFormatMessage
Text returned by mountResultMessage() when a present device fails to mount.
bool labelFetched[MAX_STORAGE_DEVICES]
fetched since the last mount/removal - see mountFAT()/invalidateStorageDevice()
virtual void prepareMount(int deviceId)
Platform-specific work that must run immediately before a user-initiated mount attempt on deviceId,...
const char * getMountPath(int device) const override
devoptab-style mount path for device (eg.
const OgcFatSlotDescriptor * findFatSlot(int deviceId) const
int fatSlotCount
Number of entries in fatSlots.
DISC_INTERFACE * dvdDisc
Disc interface used to mount the DVD drive, or nullptr if the platform has none.
const char * getDevicePrefix(int device) const override
The devoptab prefix this device would use (eg.
void shutdown() override
Unmounts every device and releases the driver's resources.
bool mountFailed[MAX_STORAGE_DEVICES]
set by a real MountFailed; cleared on removal/reinsertion - see attemptFatMount()
SmbDriver * getSmb() override
OgcSmbDriver smbDriver
The network-share driver returned by getSmb()
const char * mountResultMessage(int deviceId, MountResult result) override
A short, user-displayable reason for a non-Success MountResult (eg.
virtual bool pollPlatformExtra()
Platform-specific extra polling that must run before the shared per-slot presence check (eg.
virtual void shutdownPlatform()
Platform-specific extra teardown beyond the shared per-slot fatUnmount() pass (eg.
MountResult mountDVD()
Mounts the DVD as ISO9660 if a disc is inserted.
MountResult mountStorageDevice(int deviceId) override
Attempts to mount deviceId exactly once.
int enumerateStorageDevices(StorageDevice outDevices[MAX_STORAGE_DEVICES]) override
Fills outDevices (size MAX_STORAGE_DEVICES) and returns the device count.
bool isPresentCache[MAX_STORAGE_DEVICES]
raw hardware insertion only - see isDevicePresent()'s comment for why this is no longer what it retur...
void invalidateStorageDevice(int deviceId) override
Marks deviceId as needing a fresh mount next time mountStorageDevice() is called, eg.
Wraps libsmb2 behind a "smb:/" devoptab.
Network-share driver.
Definition SmbDriver.h:43
MountResult
Result of a single mount attempt.
One hot-pluggable FAT-formatted slot, shared shape between GameCube (SD Gecko A/B/port2,...
bool autoMountAtStartup
Mounted silently at boot.
const char * notFoundMessage
eg.
const char * displayName
Short name shown in device lists.
bool pollable
true: probed every pollStorageDevices() cycle
bool removable
advisory only - not currently read by app code
const char * prefix
precomputed "name:/" literal - returned by getMountPath()/enumerateStorageDevices() as-is
int deviceId
Device enum value this slot mounts (DEVICE_SD, DEVICE_USB, ...)
const char * mountName
devoptab basename, no colon/slash - eg.
Description of one storage device: id, display name, mount prefix, volume label and flags such as rem...