libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
OgcFileSystemDriver Class Reference

Shared GameCube/Wii FileSystemDriver base: FAT slot enumeration, mounting and polling. More...

#include <OgcFileSystemDriver.h>

Inheritance diagram for OgcFileSystemDriver:
[legend]

Public Member Functions

void shutdown () override
 Unmounts every device and releases the driver's resources.
 
int enumerateStorageDevices (StorageDevice outDevices[MAX_STORAGE_DEVICES]) override
 Fills outDevices (size MAX_STORAGE_DEVICES) and returns the device count.
 
MountResult mountStorageDevice (int deviceId) override
 Attempts to mount deviceId exactly once.
 
const char * mountResultMessage (int deviceId, MountResult result) override
 A short, user-displayable reason for a non-Success MountResult (eg.
 
void invalidateStorageDevice (int deviceId) override
 Marks deviceId as needing a fresh mount next time mountStorageDevice() is called, eg.
 
void pollStorageDevices (int removedIds[MAX_STORAGE_DEVICES], int &outRemovedCount, bool &deviceListChanged) override
 Called once per device-checking thread cycle.
 
bool hasRemovableStorageDevices () const override
 Whether the device-checking thread should run on this platform.
 
bool isDevicePresent (int deviceId) const override
 Lightweight, cached hardware-presence check for a single device - does NOT mount and does no invasive I/O.
 
const char * getDevicePrefix (int device) const override
 The devoptab prefix this device would use (eg.
 
const char * getMountPath (int device) const override
 devoptab-style mount path for device (eg.
 
SmbDriver * getSmb () override
 
- Public Member Functions inherited from FileSystemDriver
virtual void init ()=0
 Initializes the driver and auto-mounts devices flagged autoMountAtStartup.
 
template<size_t N>
void getPath (char(&out)[N], int device, const char *suffix) const
 Writes getMountPath(device) + suffix into out (bounds-checked to sizeof(out) via the array-reference template parameter N).
 
template<size_t N>
void getPath (char(&out)[N], int device, const char *folder, const char *file) const
 Joins a folder and a filename with '/' after the mount path.
 
void getPath (char *out, size_t outSize, int device, const char *suffix) const
 Explicit-size equivalents of the two templates above, for call sites where the destination buffer arrives as a char * function parameter rather than a fixed array.
 
void getPath (char *out, size_t outSize, int device, const char *folder, const char *file) const
 Joins folder and file with '/' after the mount path, as in the template above.
 
virtual const int * getValidLoadDevices (int &outCount) const =0
 Devices (Device enum values, in priority order) that are offered when choosing where to load from on this platform.
 
virtual const int * getValidSaveDevices (int &outCount) const =0
 Devices (Device enum values, in priority order) that are offered when choosing where to save to on this platform.
 

Protected Member Functions

void initFatSlotsAndAutoMount ()
 Runs the shared boot-time pass: probe every pollable fatSlots[] entry once for isPresentCache, then auto-mount whatever enumerateStorageDevices() marks autoMountAtStartup.
 
virtual void shutdownPlatform ()
 Platform-specific extra teardown beyond the shared per-slot fatUnmount() pass (eg.
 
virtual bool pollPlatformExtra ()
 Platform-specific extra polling that must run before the shared per-slot presence check (eg.
 
virtual void prepareMount (int deviceId)
 Platform-specific work that must run immediately before a user-initiated mount attempt on deviceId, so the attempt sees current hardware topology instead of whatever the last poll cycle happened to observe.
 
MountResult mountFAT (int deviceId)
 Mounts the FAT filesystem on a slot with fatMountSimple(), unmounting first if unmountRequired is set.
 
MountResult mountDVD ()
 Mounts the DVD as ISO9660 if a disc is inserted.
 
MountResult attemptFatMount (int deviceId)
 Single mountFAT() attempt that also records the outcome in mountFailed.
 
const OgcFatSlotDescriptor * findFatSlot (int deviceId) const
 

Protected Attributes

const OgcFatSlotDescriptor * fatSlots = nullptr
 Table of FAT slots this platform supports; set by the concrete driver.
 
int fatSlotCount = 0
 Number of entries in fatSlots.
 
DISC_INTERFACE * dvdDisc = nullptr
 Disc interface used to mount the DVD drive, or nullptr if the platform has none.
 
const char * unsupportedFormatMessage = "Unsupported format."
 Text returned by mountResultMessage() when a present device fails to mount.
 
bool isMounted [MAX_STORAGE_DEVICES] = { false }
 A filesystem is currently mounted for this device.
 
bool unmountRequired [MAX_STORAGE_DEVICES] = { false }
 A stale mount must be torn down before the next mount attempt.
 
bool isPresentCache [MAX_STORAGE_DEVICES] = { false }
 raw hardware insertion only - see isDevicePresent()'s comment for why this is no longer what it returns
 
bool mountFailed [MAX_STORAGE_DEVICES] = { false }
 set by a real MountFailed; cleared on removal/reinsertion - see attemptFatMount()
 
bool labelFetched [MAX_STORAGE_DEVICES] = { false }
 fetched since the last mount/removal - see mountFAT()/invalidateStorageDevice()
 
char volumeLabel [MAX_STORAGE_DEVICES][16] = { { 0 } }
 Volume label cached for each device.
 
OgcSmbDriver smbDriver
 The network-share driver returned by getSmb()
 

Detailed Description

Shared GameCube/Wii FileSystemDriver base: FAT slot enumeration, mounting and polling.

DVD is deliberately never probed while polling.

Definition at line 39 of file OgcFileSystemDriver.h.

Member Function Documentation

◆ attemptFatMount()

MountResult OgcFileSystemDriver::attemptFatMount ( int deviceId)
protected

Single mountFAT() attempt that also records the outcome in mountFailed.

Definition at line 167 of file OgcFileSystemDriver.cpp.

◆ enumerateStorageDevices()

int OgcFileSystemDriver::enumerateStorageDevices ( StorageDevice outDevices[MAX_STORAGE_DEVICES])
overridevirtual

Fills outDevices (size MAX_STORAGE_DEVICES) and returns the device count.

Implements FileSystemDriver.

Definition at line 56 of file OgcFileSystemDriver.cpp.

◆ findFatSlot()

const OgcFatSlotDescriptor * OgcFileSystemDriver::findFatSlot ( int deviceId) const
protected
Returns
the slot descriptor for deviceId, or nullptr if it is not a FAT slot

Definition at line 13 of file OgcFileSystemDriver.cpp.

◆ getDevicePrefix()

const char * OgcFileSystemDriver::getDevicePrefix ( int device) const
overridevirtual

The devoptab prefix this device would use (eg.

"usb:/"), regardless of whether it is currently mounted.

Implements FileSystemDriver.

Definition at line 290 of file OgcFileSystemDriver.cpp.

◆ getMountPath()

const char * OgcFileSystemDriver::getMountPath ( int device) const
overridevirtual

devoptab-style mount path for device (eg.

"sd:/"), or "" if device isn't recognized or currently mounted on this platform. Only for "is this usable already?" call sites - use getDevicePrefix() to map a path back to a device id.

Implements FileSystemDriver.

Definition at line 305 of file OgcFileSystemDriver.cpp.

◆ getSmb()

SmbDriver * OgcFileSystemDriver::getSmb ( )
inlineoverridevirtual
Returns
this platform's network-share driver (see SmbDriver)

Implements FileSystemDriver.

Definition at line 55 of file OgcFileSystemDriver.h.

◆ hasRemovableStorageDevices()

bool OgcFileSystemDriver::hasRemovableStorageDevices ( ) const
inlineoverridevirtual

Whether the device-checking thread should run on this platform.

Implements FileSystemDriver.

Definition at line 49 of file OgcFileSystemDriver.h.

◆ initFatSlotsAndAutoMount()

void OgcFileSystemDriver::initFatSlotsAndAutoMount ( )
protected

Runs the shared boot-time pass: probe every pollable fatSlots[] entry once for isPresentCache, then auto-mount whatever enumerateStorageDevices() marks autoMountAtStartup.

Definition at line 21 of file OgcFileSystemDriver.cpp.

◆ invalidateStorageDevice()

void OgcFileSystemDriver::invalidateStorageDevice ( int deviceId)
overridevirtual

Marks deviceId as needing a fresh mount next time mountStorageDevice() is called, eg.

after a read/write failure suggests the underlying media went away. Does no I/O itself.

Implements FileSystemDriver.

Definition at line 213 of file OgcFileSystemDriver.cpp.

◆ isDevicePresent()

bool OgcFileSystemDriver::isDevicePresent ( int deviceId) const
overridevirtual

Lightweight, cached hardware-presence check for a single device - does NOT mount and does no invasive I/O.

Backed by whatever pollStorageDevices() last observed

Implements FileSystemDriver.

Definition at line 275 of file OgcFileSystemDriver.cpp.

◆ mountDVD()

MountResult OgcFileSystemDriver::mountDVD ( )
protected

Mounts the DVD as ISO9660 if a disc is inserted.

Definition at line 137 of file OgcFileSystemDriver.cpp.

◆ mountFAT()

MountResult OgcFileSystemDriver::mountFAT ( int deviceId)
protected

Mounts the FAT filesystem on a slot with fatMountSimple(), unmounting first if unmountRequired is set.

Definition at line 91 of file OgcFileSystemDriver.cpp.

◆ mountResultMessage()

const char * OgcFileSystemDriver::mountResultMessage ( int deviceId,
MountResult result )
overridevirtual

A short, user-displayable reason for a non-Success MountResult (eg.

"SD card not found!"). Never returns nullptr.

Implements FileSystemDriver.

Definition at line 198 of file OgcFileSystemDriver.cpp.

◆ mountStorageDevice()

MountResult OgcFileSystemDriver::mountStorageDevice ( int deviceId)
overridevirtual

Attempts to mount deviceId exactly once.

No retry, no prompts, no-ops (returns Success) if already mounted.

Implements FileSystemDriver.

Definition at line 174 of file OgcFileSystemDriver.cpp.

◆ pollPlatformExtra()

virtual bool OgcFileSystemDriver::pollPlatformExtra ( )
inlineprotectedvirtual

Platform-specific extra polling that must run before the shared per-slot presence check (eg.

Wii's WiiUsbMulti::scan(), which re-resolves which physical interface each USB slot's getDisc() currently points at). Returns true if this alone constitutes a device-list change. No-op/false by default.

Reimplemented in WiiFileSystemDriver.

Definition at line 81 of file OgcFileSystemDriver.h.

◆ pollStorageDevices()

void OgcFileSystemDriver::pollStorageDevices ( int removedIds[MAX_STORAGE_DEVICES],
int & outRemovedCount,
bool & deviceListChanged )
overridevirtual

Called once per device-checking thread cycle.

removedIds/outRemovedCount: devices that were mounted and have now disappeared (already invalidated internally - callers just need to react, eg. abort an in-progress directory parse). deviceListChanged: true if enumerateStorageDevices() should be re-run because the device table itself changed shape.

Implements FileSystemDriver.

Definition at line 234 of file OgcFileSystemDriver.cpp.

◆ prepareMount()

virtual void OgcFileSystemDriver::prepareMount ( int deviceId)
inlineprotectedvirtual

Platform-specific work that must run immediately before a user-initiated mount attempt on deviceId, so the attempt sees current hardware topology instead of whatever the last poll cycle happened to observe.

Reimplemented in WiiFileSystemDriver.

Definition at line 87 of file OgcFileSystemDriver.h.

◆ shutdown()

void OgcFileSystemDriver::shutdown ( )
overridevirtual

Unmounts every device and releases the driver's resources.

Implements FileSystemDriver.

Definition at line 42 of file OgcFileSystemDriver.cpp.

◆ shutdownPlatform()

virtual void OgcFileSystemDriver::shutdownPlatform ( )
inlineprotectedvirtual

Platform-specific extra teardown beyond the shared per-slot fatUnmount() pass (eg.

Wii's WiiUsbMulti/USBStorage/DI_Close()).

Reimplemented in WiiFileSystemDriver.

Definition at line 74 of file OgcFileSystemDriver.h.

Member Data Documentation

◆ dvdDisc

DISC_INTERFACE* OgcFileSystemDriver::dvdDisc = nullptr
protected

Disc interface used to mount the DVD drive, or nullptr if the platform has none.

Definition at line 63 of file OgcFileSystemDriver.h.

◆ fatSlotCount

int OgcFileSystemDriver::fatSlotCount = 0
protected

Number of entries in fatSlots.

Definition at line 61 of file OgcFileSystemDriver.h.

◆ fatSlots

const OgcFatSlotDescriptor* OgcFileSystemDriver::fatSlots = nullptr
protected

Table of FAT slots this platform supports; set by the concrete driver.

Definition at line 59 of file OgcFileSystemDriver.h.

◆ isMounted

bool OgcFileSystemDriver::isMounted[MAX_STORAGE_DEVICES] = { false }
protected

A filesystem is currently mounted for this device.

Definition at line 99 of file OgcFileSystemDriver.h.

◆ isPresentCache

bool OgcFileSystemDriver::isPresentCache[MAX_STORAGE_DEVICES] = { false }
protected

raw hardware insertion only - see isDevicePresent()'s comment for why this is no longer what it returns

Definition at line 101 of file OgcFileSystemDriver.h.

◆ labelFetched

bool OgcFileSystemDriver::labelFetched[MAX_STORAGE_DEVICES] = { false }
protected

fetched since the last mount/removal - see mountFAT()/invalidateStorageDevice()

Definition at line 103 of file OgcFileSystemDriver.h.

◆ mountFailed

bool OgcFileSystemDriver::mountFailed[MAX_STORAGE_DEVICES] = { false }
protected

set by a real MountFailed; cleared on removal/reinsertion - see attemptFatMount()

Definition at line 102 of file OgcFileSystemDriver.h.

◆ smbDriver

OgcSmbDriver OgcFileSystemDriver::smbDriver
protected

The network-share driver returned by getSmb()

Definition at line 107 of file OgcFileSystemDriver.h.

◆ unmountRequired

bool OgcFileSystemDriver::unmountRequired[MAX_STORAGE_DEVICES] = { false }
protected

A stale mount must be torn down before the next mount attempt.

Definition at line 100 of file OgcFileSystemDriver.h.

◆ unsupportedFormatMessage

const char* OgcFileSystemDriver::unsupportedFormatMessage = "Unsupported format."
protected

Text returned by mountResultMessage() when a present device fails to mount.

Definition at line 65 of file OgcFileSystemDriver.h.

◆ volumeLabel

char OgcFileSystemDriver::volumeLabel[MAX_STORAGE_DEVICES][16] = { { 0 } }
protected

Volume label cached for each device.

Definition at line 104 of file OgcFileSystemDriver.h.


The documentation for this class was generated from the following files: