11#include "OgcFileSystemDriver.h"
28 DISC_INTERFACE * disc =
fatSlots[i].getDisc();
37 for(
int i = 0; i < count; i++)
38 if(devices[i].autoMountAtStartup)
49 snprintf(mountPoint,
sizeof(mountPoint),
"%s:",
fatSlots[i].mountName);
50 fatUnmount(mountPoint);
60 for(
int i = 0; i <
fatSlotCount && count < MAX_STORAGE_DEVICES; i++)
76 if(count < MAX_STORAGE_DEVICES)
78 outDevices[count] =
StorageDevice{ DEVICE_DVD,
"dvd:/",
"Data DVD",
"",
false,
false,
true };
82 if(count < MAX_STORAGE_DEVICES)
84 outDevices[count] =
StorageDevice{ DEVICE_SMB,
"smb:/",
"Network Share",
"",
false,
false,
true };
98 snprintf(mountPoint,
sizeof(mountPoint),
"%s:", slot->
mountName);
100 DISC_INTERFACE * disc = slot->
getDisc();
105 fatUnmount(mountPoint);
106 disc->shutdown(disc);
112 if(!disc->startup(disc) || !disc->isInserted(disc))
120 bool mounted = fatMountSimple(slot->
mountName, disc);
130 fatGetVolumeLabel(mountPoint,
volumeLabel[deviceId]);
145 ISO9660_Unmount(
"dvd:");
157 if(!ISO9660_Mount(
"dvd",
dvdDisc))
164 return MountResult::Success;
176 if(deviceId < 0 || deviceId >= MAX_STORAGE_DEVICES)
179 if(deviceId == DEVICE_SMB)
183 return MountResult::Success;
189 if(deviceId == DEVICE_DVD)
200 if(deviceId == DEVICE_DVD)
203 if(deviceId == DEVICE_SMB)
204 return "Network share not connected!";
208 return "Device not found!";
215 if(deviceId < 0 || deviceId >= MAX_STORAGE_DEVICES)
218 if(deviceId == DEVICE_SMB)
248 DISC_INTERFACE * disc = slot.
getDisc();
249 bool present = disc->isInserted(disc);
262 if(outRemovedCount < MAX_STORAGE_DEVICES)
263 removedIds[outRemovedCount++] = slot.
deviceId;
264 deviceListChanged =
true;
270 deviceListChanged =
true;
277 if(deviceId == DEVICE_SMB)
280 if(deviceId == DEVICE_DVD)
292 if(device < 0 || device >= MAX_STORAGE_DEVICES)
295 if(device == DEVICE_SMB)
298 if(device == DEVICE_DVD)
302 return slot ? slot->
prefix :
"";
307 if(device < 0 || device >= MAX_STORAGE_DEVICES)
310 if(device == DEVICE_SMB)
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,...
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()
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.
MountResult
Result of a single mount attempt.
@ MountFailed
present, but couldn't be mounted (eg.
@ DeviceNotFound
not physically present / not inserted
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
DISC_INTERFACE *(* getDisc)()
resolved lazily - Wii's USB slots move between physical interfaces at runtime (see WiiUsbMulti)
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...
bool autoMountAtStartup
silently attempted at boot
bool removable
can this device disappear at runtime?
int id
Device enum value (DEVICE_SD, DEVICE_USB, ...)
bool alwaysListed
show in a device listing unconditionally, regardless of isDevicePresent()
char volumeLabel[16]
Volume label of the mounted filesystem, or empty if unknown.
char prefix[32]
devoptab mount prefix, eg.
char name[20]
Short display name for device lists.