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

SD: a plain WHBMountSdCard() FSA mount, done once in init(). More...

#include <WutFileSystemDriver.h>

Inheritance diagram for WutFileSystemDriver:
[legend]

Public Member Functions

void init () override
 Initializes the driver and auto-mounts devices flagged autoMountAtStartup.
 
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.
 
const int * getValidLoadDevices (int &outCount) const override
 Devices (Device enum values, in priority order) that are offered when choosing where to load from on this platform.
 
const int * getValidSaveDevices (int &outCount) const override
 Devices (Device enum values, in priority order) that are offered when choosing where to save to on this platform.
 
SmbDriver * getSmb () override
 
- Public Member Functions inherited from FileSystemDriver
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.
 

Detailed Description

SD: a plain WHBMountSdCard() FSA mount, done once in init().

From then on it is assumed always present and always mounted.

USB: stock Cafe OS has no FAT/exFAT/NTFS driver at all, so mounting always goes through libdvm - which also supplies genuine hot-unplug detection via dvmWutVolumeStillPresent(). Raw disc access below libdvm is through libmocha's DISC_INTERFACE, and is unavailable entirely if Mocha isn't present.

Hotplug (insertion): Mocha_*_isInserted() only reports whether we already have the fd open - it doesn't re-probe hardware. While unmounted, pollStorageDevices() retries dvmWutMountVolume(). A read-only nsysuhs scan resets USB's backoff immediately on any real hardware-level change.

Hotplug (removal while mounted): dvmWutVolumeStillPresent() forces a real, uncached raw sector read through the mounted disc.

Backoff: a slot that opens but won't mount (wrong/unrecognized format, or genuinely nothing there) gets a few quick immediate retries. The interface is always left shutdown() between attempts.

Volume labels (USB only): looked up once via libdvm (dvmWutGetVolumeLabel()) right after a successful mount, never repeated until the next unmount/remount cycle - see getVolumeLabel().

Definition at line 66 of file WutFileSystemDriver.h.

Member Function Documentation

◆ enumerateStorageDevices()

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

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

Implements FileSystemDriver.

Definition at line 276 of file WutFileSystemDriver.cpp.

◆ getDevicePrefix()

const char * WutFileSystemDriver::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 419 of file WutFileSystemDriver.cpp.

◆ getMountPath()

const char * WutFileSystemDriver::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 425 of file WutFileSystemDriver.cpp.

◆ getSmb()

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

Implements FileSystemDriver.

Definition at line 85 of file WutFileSystemDriver.h.

◆ getValidLoadDevices()

const int * WutFileSystemDriver::getValidLoadDevices ( int & outCount) const
overridevirtual

Devices (Device enum values, in priority order) that are offered when choosing where to load from on this platform.

Parameters
outCountreceives the number of entries in the returned array
Returns
a static array owned by the driver

Implements FileSystemDriver.

Definition at line 436 of file WutFileSystemDriver.cpp.

◆ getValidSaveDevices()

const int * WutFileSystemDriver::getValidSaveDevices ( int & outCount) const
overridevirtual

Devices (Device enum values, in priority order) that are offered when choosing where to save to on this platform.

Differs from the load list in that read-only devices such as DVD are left out.

Parameters
outCountreceives the number of entries in the returned array
Returns
a static array owned by the driver

Implements FileSystemDriver.

Definition at line 443 of file WutFileSystemDriver.cpp.

◆ hasRemovableStorageDevices()

bool WutFileSystemDriver::hasRemovableStorageDevices ( ) const
inlineoverridevirtual

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

Implements FileSystemDriver.

Definition at line 77 of file WutFileSystemDriver.h.

◆ init()

void WutFileSystemDriver::init ( )
overridevirtual

Initializes the driver and auto-mounts devices flagged autoMountAtStartup.

Implements FileSystemDriver.

Definition at line 54 of file WutFileSystemDriver.cpp.

◆ invalidateStorageDevice()

void WutFileSystemDriver::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 349 of file WutFileSystemDriver.cpp.

◆ isDevicePresent()

bool WutFileSystemDriver::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 305 of file WutFileSystemDriver.cpp.

◆ mountResultMessage()

const char * WutFileSystemDriver::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 334 of file WutFileSystemDriver.cpp.

◆ mountStorageDevice()

MountResult WutFileSystemDriver::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 314 of file WutFileSystemDriver.cpp.

◆ pollStorageDevices()

void WutFileSystemDriver::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 370 of file WutFileSystemDriver.cpp.

◆ shutdown()

void WutFileSystemDriver::shutdown ( )
overridevirtual

Unmounts every device and releases the driver's resources.

Implements FileSystemDriver.

Definition at line 121 of file WutFileSystemDriver.cpp.


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