libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Network shares (SMB)

FileSystemDriver::getSmb() returns the platform's SmbDriver, which mounts a single SMB share as the DEVICE_SMB device at smb:/. GameCube and Wii use OgcSmbDriver; Wii U uses WutSmbDriver. Both are built on libsmb2 and register an smb:/ devoptab, so once connected the share behaves like any other mounted device.

SmbShareInfo share = {}; // host, share, user, password (empty user = guest)
snprintf(share.host, sizeof(share.host), "192.168.0.100");
snprintf(share.share, sizeof(share.share), "Files");
SmbDriver * smb = platform->getFileSystem()->getSmb();
SmbConnectResult result = smb->connect(share); // brings the network up first if needed
if(result != SmbConnectResult::Success)
showError(smb->connectResultMessage(result), smb->getLastError());
else
FILE * f = fopen("smb:/roms/game.sfc", "rb");
Network-share driver.
Definition SmbDriver.h:43
virtual const char * getLastError() const
Raw, implementation-specific detail behind the last failure.
Definition SmbDriver.h:83
virtual SmbConnectResult connect(const SmbShareInfo &info)=0
Attempts to connect and mount in one call.
virtual const char * connectResultMessage(SmbConnectResult result) const =0
Short, user-displayable reason for a non-Success SmbConnectResult.
SmbConnectResult
Result of a single connect() attempt.
Definition SmbDriver.h:33
Credentials/target for a single SMB share.
Definition SmbDriver.h:20
char share[64]
share name, eg.
Definition SmbDriver.h:22
char host[64]
server IP or hostname
Definition SmbDriver.h:21

connect() brings the console's network connection up if it isn't already (GameCube/Wii via libogc's network stack; Wii U via the system's network account service), and is a no-op if already connected to the same share. Results are Success, InvalidSettings (no host or share), NetworkUnavailable, or ConnectFailed (the network is up but the server, share, or credentials were rejected); getLastError() adds libsmb2's own detail, such as an access-denied or host-resolution message. disconnect() unmounts the share. The demo's Network Share screen shows the whole flow.

Back to the README