MCPcopy Create free account
hub / github.com/devkitPro/libctru / _archiveMountDevice

Function _archiveMountDevice

libctru/source/archive_dev.c:280–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static int _archiveMountDevice(FS_Archive archive,
281 const char *deviceName,
282 archive_fsdevice **out_device)
283{
284 archive_fsdevice *device = NULL;
285
286 if (archiveFindDevice(deviceName)) //Device is already mounted with the same name
287 goto _fail;
288
289 _archiveInit(); //Ensure driver is initialized
290
291 device = archiveFindDevice(NULL);
292 if(device==NULL)
293 goto _fail;
294
295 device->archive = archive;
296 memset(device->name, 0, sizeof(device->name));
297 strncpy(device->name, deviceName, sizeof(device->name)-1);
298
299 int dev = AddDevice(&device->device);
300 if(dev==-1)
301 goto _fail;
302
303 device->setup = 1;
304 device->cwd = malloc(PATH_MAX+1);
305 device->cwd[0] = '/';
306 device->cwd[1] = '\0';
307
308 if (archive_device_cwd==-1)
309 archive_device_cwd = device->id;
310
311 const devoptab_t *default_dev = GetDeviceOpTab("");
312 if(default_dev==NULL || strcmp(default_dev->name, "stdnull")==0)
313 setDefaultDevice(dev);
314
315 if(out_device != NULL)
316 *out_device=device;
317
318 return dev;
319
320_fail:
321 FSUSER_CloseArchive(archive);
322 return -1;
323}
324
325Result archiveMount(FS_ArchiveID archiveID,
326 FS_Path archivePath,

Callers 2

archiveMountFunction · 0.85
archiveMountSdmcFunction · 0.85

Calls 3

archiveFindDeviceFunction · 0.85
_archiveInitFunction · 0.85
FSUSER_CloseArchiveFunction · 0.85

Tested by

no test coverage detected