Merge pull request #116 from profi200/master

Added AM_GetCiaFileInfo() and FSUSER_DeleteDirectoryRecursively().
This commit is contained in:
smea 2015-05-09 13:46:56 -07:00
commit d30d14dff4
4 changed files with 79 additions and 3 deletions

View File

@ -116,3 +116,12 @@ About: Gets the product code of a title based on its title id.
productcode buffer to output the product code to (should have a length of 16) productcode buffer to output the product code to (should have a length of 16)
*/ */
Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode); Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode);
/* AM_GetCiaFileInfo()
About: Reads a CIA file and returns a TitleList entry for it.
mediatype destination mediatype
titleEntry ptr to a TitleList entry
fileHandle a fs:USER file handle for a CIA file
*/
Result AM_GetCiaFileInfo(u8 mediatype, TitleList *titleEntry, Handle fileHandle);

View File

@ -142,6 +142,7 @@ Result FSUSER_CreateFile(Handle* handle, FS_archive archive, FS_path fileLowPath
Result FSUSER_CreateDirectory(Handle* handle, FS_archive archive, FS_path dirLowPath); Result FSUSER_CreateDirectory(Handle* handle, FS_archive archive, FS_path dirLowPath);
Result FSUSER_DeleteFile(Handle *handle, FS_archive archive, FS_path fileLowPath); Result FSUSER_DeleteFile(Handle *handle, FS_archive archive, FS_path fileLowPath);
Result FSUSER_DeleteDirectory(Handle *handle, FS_archive archive, FS_path dirLowPath); 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_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_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_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);

View File

@ -200,3 +200,20 @@ Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode)
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
Result AM_GetCiaFileInfo(u8 mediatype, TitleList *titleEntry, Handle fileHandle)
{
Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x04080042;
cmdbuf[1] = mediatype;
cmdbuf[2] = 0;
cmdbuf[3] = fileHandle;
if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
if(titleEntry) memcpy(titleEntry, &cmdbuf[2], sizeof(TitleList));
return (Result)cmdbuf[1];
}

View File

@ -458,11 +458,60 @@ FSUSER_DeleteDirectory(Handle *handle,
return cmdbuf[1]; return cmdbuf[1];
} }
/* stub */ /*! 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
*
* @returns error
*
* @internal
*
* #### Request
*
* Index Word | Description
* -----------|-------------------------
* 0 | Header code [0x08070142]
* 1 | 0
* 2 | archive.handleLow
* 3 | archive.handleHigh
* 4 | dirLowPath.type
* 5 | dirLowPath.size
* 6 | (dirLowPath.size << 14) \| 0x2
* 7 | dirLowPath.data
*
* #### Response
*
* Index Word | Description
* -----------|-------------------------
* 0 | Header code
* 1 | Result code
*/
Result Result
FSUSER_DeleteDirectoryRecursively(void) FSUSER_DeleteDirectoryRecursively(Handle *handle,
FS_archive archive,
FS_path dirLowPath)
{ {
return -1; if(!handle)
handle = &fsuHandle;
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x08070142;
cmdbuf[1] = 0;
cmdbuf[2] = archive.handleLow;
cmdbuf[3] = archive.handleHigh;
cmdbuf[4] = dirLowPath.type;
cmdbuf[5] = dirLowPath.size;
cmdbuf[6] = (dirLowPath.size << 14) | 0x2;
cmdbuf[7] = (u32)dirLowPath.data;
Result ret = 0;
if((ret = svcSendSyncRequest(*handle)))
return ret;
return cmdbuf[1];
} }
/*! Create a File /*! Create a File