Result fsInit(void);
Result fsExit(void);
-Handle *fsGetSessionHandle();
+Handle *fsGetSessionHandle(void);
FS_path FS_makePath(FS_pathType type, const char *path);
-Result FSUSER_Initialize(Handle* handle);
-Result FSUSER_OpenArchive(Handle* handle, FS_archive* archive);
-Result FSUSER_OpenDirectory(Handle* handle, Handle* out, FS_archive archive, FS_path dirLowPath);
-Result FSUSER_OpenFile(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
-Result FSUSER_OpenFileDirectly(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
-Result FSUSER_CloseArchive(Handle* handle, FS_archive* archive);
-Result FSUSER_CreateFile(Handle* handle, FS_archive archive, FS_path fileLowPath, u32 fileSize);
-Result FSUSER_CreateDirectory(Handle* handle, FS_archive archive, FS_path dirLowPath);
-Result FSUSER_DeleteFile(Handle *handle, FS_archive archive, FS_path fileLowPath);
-Result FSUSER_DeleteDirectory(Handle *handle, FS_archive archive, FS_path dirLowPath);
-Result FSUSER_DeleteDirectoryRecursively(Handle *handle, FS_archive archive, FS_path dirLowPath);
-Result FSUSER_RenameFile(Handle *handle, FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath);
-Result FSUSER_RenameDirectory(Handle *handle, FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath);
-Result FSUSER_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
-Result FSUSER_GetNandArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
-Result FSUSER_IsSdmcDetected(Handle *handle, u8 *detected);
-Result FSUSER_IsSdmcWritable(Handle *handle, u8 *writable);
+Result FSUSER_Initialize(void);
+Result FSUSER_OpenArchive(FS_archive* archive);
+Result FSUSER_OpenDirectory(Handle* out, FS_archive archive, FS_path dirLowPath);
+Result FSUSER_OpenFile(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
+Result FSUSER_OpenFileDirectly(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
+Result FSUSER_CloseArchive(FS_archive* archive);
+Result FSUSER_CreateFile(FS_archive archive, FS_path fileLowPath, u32 fileSize);
+Result FSUSER_CreateDirectory(FS_archive archive, FS_path dirLowPath);
+Result FSUSER_DeleteFile(FS_archive archive, FS_path fileLowPath);
+Result FSUSER_DeleteDirectory(FS_archive archive, FS_path dirLowPath);
+Result FSUSER_DeleteDirectoryRecursively(FS_archive archive, FS_path dirLowPath);
+Result FSUSER_RenameFile(FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath);
+Result FSUSER_RenameDirectory(FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath);
+Result FSUSER_GetSdmcArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
+Result FSUSER_GetNandArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
+Result FSUSER_IsSdmcDetected(u8 *detected);
+Result FSUSER_IsSdmcWritable(u8 *writable);
Result FSFILE_Close(Handle handle);
Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size);
if(sdmcInitialised)
return rc;
- rc = FSUSER_OpenArchive(NULL, &sdmcArchive);
+ rc = FSUSER_OpenArchive(&sdmcArchive);
if(rc == 0)
{
if(!sdmcInitialised) return rc;
- rc = FSUSER_CloseArchive(NULL, &sdmcArchive);
+ rc = FSUSER_CloseArchive(&sdmcArchive);
if(rc == 0)
{
RemoveDevice("sdmc");
/* Test O_EXCL. */
if((flags & O_CREAT) && (flags & O_EXCL))
{
- rc = FSUSER_CreateFile(NULL, sdmcArchive, fs_path, 0);
+ rc = FSUSER_CreateFile(sdmcArchive, fs_path, 0);
if(rc != 0)
{
r->_errno = sdmc_translate_error(rc);
attributes |= FS_ATTRIBUTE_READONLY;*/
/* open the file */
- rc = FSUSER_OpenFile(NULL, &fd, sdmcArchive, fs_path,
+ rc = FSUSER_OpenFile(&fd, sdmcArchive, fs_path,
sdmc_flags, attributes);
if(rc == 0)
{
if(fs_path.data == NULL)
return -1;
- if((rc = FSUSER_OpenFile(NULL, &fd, sdmcArchive, fs_path,
+ if((rc = FSUSER_OpenFile(&fd, sdmcArchive, fs_path,
FS_OPEN_READ, FS_ATTRIBUTE_NONE)) == 0)
{
sdmc_file_t tmpfd = { .fd = fd };
return rc;
}
- else if((rc = FSUSER_OpenDirectory(NULL, &fd, sdmcArchive, fs_path)) == 0)
+ else if((rc = FSUSER_OpenDirectory(&fd, sdmcArchive, fs_path)) == 0)
{
memset(st, 0, sizeof(struct stat));
st->st_nlink = 1;
if(fs_path.data == NULL)
return -1;
- rc = FSUSER_DeleteFile(NULL, sdmcArchive, fs_path);
+ rc = FSUSER_DeleteFile(sdmcArchive, fs_path);
if(rc == 0)
return 0;
if(fs_path.data == NULL)
return -1;
- rc = FSUSER_OpenDirectory(NULL, &fd, sdmcArchive, fs_path);
+ rc = FSUSER_OpenDirectory(&fd, sdmcArchive, fs_path);
if(rc == 0)
{
FSDIR_Close(fd);
if(fs_path_new.data == NULL)
return -1;
- rc = FSUSER_RenameFile(NULL, sdmcArchive, fs_path_old, sdmcArchive, fs_path_new);
+ rc = FSUSER_RenameFile(sdmcArchive, fs_path_old, sdmcArchive, fs_path_new);
if(rc == 0)
return 0;
- rc = FSUSER_RenameDirectory(NULL, sdmcArchive, fs_path_old, sdmcArchive, fs_path_new);
+ rc = FSUSER_RenameDirectory(sdmcArchive, fs_path_old, sdmcArchive, fs_path_new);
if(rc == 0)
return 0;
/* TODO: Use mode to set directory attributes. */
- rc = FSUSER_CreateDirectory(NULL, sdmcArchive, fs_path);
+ rc = FSUSER_CreateDirectory(sdmcArchive, fs_path);
if(rc == 0)
return 0;
sdmc_dir_t *dir = (sdmc_dir_t*)(dirState->dirStruct);
/* open the directory */
- rc = FSUSER_OpenDirectory(NULL, &fd, sdmcArchive, fs_path);
+ rc = FSUSER_OpenDirectory(&fd, sdmcArchive, fs_path);
if(rc == 0)
{
dir->fd = fd;
u8 writable = 0;
rc = FSUSER_GetSdmcArchiveResource(NULL,
- NULL,
&clusterSize,
&numClusters,
&freeClusters);
buf->f_flag = ST_NOSUID;
buf->f_namemax = 0; //??? how to get
- rc = FSUSER_IsSdmcWritable(NULL, &writable);
+ rc = FSUSER_IsSdmcWritable(&writable);
if(rc != 0 || !writable)
buf->f_flag |= ST_RDONLY;
if(fs_path.data == NULL)
return -1;
- rc = FSUSER_DeleteDirectory(NULL, sdmcArchive, fs_path);
+ rc = FSUSER_DeleteDirectory(sdmcArchive, fs_path);
if(rc == 0)
return 0;
if (fsInitialised) return ret;
if((ret=srvGetServiceHandle(&fsuHandle, "fs:USER"))!=0)return ret;
- if(__get_handle_from_list("fs:USER")==0)ret=FSUSER_Initialize(NULL);
+ if(__get_handle_from_list("fs:USER")==0)ret=FSUSER_Initialize();
fsInitialised = true;
*
* @returns Handle
*/
-Handle *fsGetSessionHandle()
+Handle *fsGetSessionHandle(void)
{
return &fsuHandle;
}
/*! Initialize FS service handle
- *
- * If @a handle is NULL, this initializes @ref fsuHandle.
- *
- * @param[in] handle fs:USER service handle
*
* @returns error
*
* 1 | Result code
*/
Result
-FSUSER_Initialize(Handle* handle)
+FSUSER_Initialize(void)
{
- if(!handle)
- {
- // don't run command if we got handle from the list
- handle = &fsuHandle;
- if(fsuHandle != 0 && __get_handle_from_list("fs:USER")!=0)
- return 0;
- }
+ // don't run command if we got handle from the list
+ if(fsuHandle != 0 && __get_handle_from_list("fs:USER")!=0)
+ return 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[1] = 0x20;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Open a file
*
- * @param[in] handle fs:USER handle
* @param[out] out Output handle
* @param[in] archive Open archive
* @param[in] fileLowPath File path
* 3 | File handle
*/
Result
-FSUSER_OpenFile(Handle *handle,
- Handle *out,
+FSUSER_OpenFile(Handle *out,
FS_archive archive,
FS_path fileLowPath,
u32 openFlags,
u32 attributes)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080201C2;
cmdbuf[9] = (u32)fileLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(out)
/*! Open a file
*
- * @param[in] handle fs:USER handle
* @param[out] out Output handle
* @param[in] archive Open archive
* @param[in] fileLowPath File path
* 3 | File handle
*/
Result
-FSUSER_OpenFileDirectly(Handle *handle,
- Handle *out,
+FSUSER_OpenFileDirectly(Handle *out,
FS_archive archive,
FS_path fileLowPath,
u32 openFlags,
u32 attributes)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[ 0] = 0x08030204;
cmdbuf[12] = (u32)fileLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(out)
/*! Delete a file
*
- * @param[in] handle fs:USER handle
* @param[in] archive Open archive
* @param[in] fileLowPath File path
*
* 1 | Result code
*/
Result
-FSUSER_DeleteFile(Handle *handle,
- FS_archive archive,
+FSUSER_DeleteFile(FS_archive archive,
FS_path fileLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08040142;
cmdbuf[7] = (u32)fileLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Renames or moves a file.
*
- * @param[in] handle fs:USER handle
* @param[in] srcArchive Open archive of source
* @param[in] srcFileLowPath File path to source
* @param[in] destArchive Open archive of destination
* 1 | Result code
*/
Result
-FSUSER_RenameFile(Handle *handle,
- FS_archive srcArchive,
+FSUSER_RenameFile(FS_archive srcArchive,
FS_path srcFileLowPath,
FS_archive destArchive,
FS_path destFileLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08050244;
cmdbuf[13] = (u32)destFileLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Delete a directory
*
- * @param[in] handle fs:USER handle
* @param[in] archive Open archive
* @param[in] dirLowPath Directory path
*
* 1 | Result code
*/
Result
-FSUSER_DeleteDirectory(Handle *handle,
- FS_archive archive,
+FSUSER_DeleteDirectory(FS_archive archive,
FS_path dirLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08060142;
cmdbuf[7] = (u32)dirLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Delete a directory and all sub directories/files recursively
*
- * @param[in] handle fs:USER handle
* @param[in] archive Open archive
* @param[in] dirLowPath Directory path
*
* 1 | Result code
*/
Result
-FSUSER_DeleteDirectoryRecursively(Handle *handle,
- FS_archive archive,
+FSUSER_DeleteDirectoryRecursively(FS_archive archive,
FS_path dirLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08070142;
cmdbuf[7] = (u32)dirLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Create a File
*
- * @param[in] handle fs:USER handle
* @param[in] archive Open archive
* @param[in] fileLowPath File path
* @param[in] fileSize Size of new file in bytes
* 1 | Result code
*/
Result
-FSUSER_CreateFile(Handle* handle,
- FS_archive archive,
- FS_path fileLowPath,
+FSUSER_CreateFile(FS_archive archive,
+ FS_path fileLowPath,
u32 fileSize)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08080202;
cmdbuf[10] = (u32)fileLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Create a directory
*
- * @param[in] handle fs:USER handle
* @param[in] archive Open archive
* @param[in] dirLowPath Directory path to create
*
* 1 | Result code
*/
Result
-FSUSER_CreateDirectory(Handle *handle,
- FS_archive archive,
+FSUSER_CreateDirectory(FS_archive archive,
FS_path dirLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08090182;
cmdbuf[8] = (u32)dirLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Renames or moves a directory.
*
- * @param[in] handle fs:USER handle
* @param[in] srcArchive Open archive of source
* @param[in] srcDirLowPath Dir path to source
* @param[in] destArchive Open archive of destination
* 1 | Result code
*/
Result
-FSUSER_RenameDirectory(Handle *handle,
- FS_archive srcArchive,
+FSUSER_RenameDirectory(FS_archive srcArchive,
FS_path srcDirLowPath,
FS_archive destArchive,
FS_path destDirLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080A0244;
cmdbuf[13] = (u32)destDirLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Open a directory
*
- * @param[in] handle fs:USER handle
* @param[out] out Output handle
* @param[in] archive Open archive
* @param[in] dirLowPath Directory path
* 2 | Directory handle
*/
Result
-FSUSER_OpenDirectory(Handle *handle,
- Handle *out,
+FSUSER_OpenDirectory(Handle *out,
FS_archive archive,
FS_path dirLowPath)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080B0102;
cmdbuf[6] = (u32)dirLowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(out)
/*! Open an archive
*
- * @param[in] handle fs:USER handle
* @param[in,out] archive Archive to open
*
* @returns error
* 3 | archive->handleHigh
*/
Result
-FSUSER_OpenArchive(Handle *handle,
- FS_archive *archive)
+FSUSER_OpenArchive(FS_archive *archive)
{
if(!archive)
return -2;
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080C00C2;
cmdbuf[5] = (u32)archive->lowPath.data;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
archive->handleLow = cmdbuf[2];
/*! Close an open archive
*
- * @param[in] handle fs:USER handle
* @param[in,out] archive Archive to close
*
* @returns error
* 1 | Result code
*/
Result
-FSUSER_CloseArchive(Handle *handle,
- FS_archive *archive)
+FSUSER_CloseArchive(FS_archive *archive)
{
if(!archive)
return -2;
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x080E0080;
cmdbuf[2] = archive->handleHigh;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
return cmdbuf[1];
/*! Get SD FAT information
*
- * @param[in] handle fs:USER handle
* @param[out] sectorSize Sector size (bytes)
* @param[out] clusterSize Cluster size (bytes)
* @param[out] numClusters Total number of clusters
* 5 | Free space (clusters)
*/
Result
-FSUSER_GetSdmcArchiveResource(Handle *handle,
- u32 *sectorSize,
+FSUSER_GetSdmcArchiveResource(u32 *sectorSize,
u32 *clusterSize,
u32 *numClusters,
u32 *freeClusters)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08140000;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(sectorSize)
/*! Get NAND information
*
- * @param[in] handle fs:USER handle
* @param[out] sectorSize Sector size (bytes)
* @param[out] clusterSize Cluster size (bytes)
* @param[out] numClusters Total number of clusters
* 5 | Free space (clusters)
*/
Result
-FSUSER_GetNandArchiveResource(Handle *handle,
- u32 *sectorSize,
+FSUSER_GetNandArchiveResource(u32 *sectorSize,
u32 *clusterSize,
u32 *numClusters,
u32 *freeClusters)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08150000;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(sectorSize)
/*! Check if SD card is detected
*
- * @param[in] handle fs:USER handle
* @param[out] detected Output detected state
*
* @returns error
* 2 | Whether SD is detected
*/
Result
-FSUSER_IsSdmcDetected(Handle *handle,
- u8 *detected)
+FSUSER_IsSdmcDetected(u8 *detected)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08170000;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(detected)
/*! Check if SD card is writable
*
- * @param[in] handle fs:USER handle
* @param[out] writable Output writable state
*
* @returns error
* 2 | Whether SD is writable
*/
Result
-FSUSER_IsSdmcWritable(Handle *handle,
- u8 *writable)
+FSUSER_IsSdmcWritable(u8 *writable)
{
- if(!handle)
- handle = &fsuHandle;
-
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08180000;
Result ret = 0;
- if((ret = svcSendSyncRequest(*handle)))
+ if((ret = svcSendSyncRequest(fsuHandle)))
return ret;
if(writable)