]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added AM_GetCiaFileInfo() and FSUSER_DeleteDirectoryRecursively().
authorprofi200 <fd3194@gmx.de>
Thu, 30 Apr 2015 11:56:22 +0000 (13:56 +0200)
committerprofi200 <fd3194@gmx.de>
Mon, 4 May 2015 17:29:13 +0000 (19:29 +0200)
libctru/include/3ds/services/am.h
libctru/include/3ds/services/fs.h
libctru/source/services/am.c
libctru/source/services/fs.c

index 06ce9575e6473acc0a856a599829f21b1bac88ef..bf8bc953d283430ef063e48b287e1add712c1ce4 100644 (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) 
 */
 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);
index b1498ae50b56b0c7e5594ec0e146d1a26add0f6f..be53a4d1aac0d17fa8364778c0f55ea05d14f28d 100644 (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_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);
index a6f6cb3eb6a6676abfc6d453125ef4c2fb8e02e9..8c0d530e2151325440ee01811173453b21df8c60 100644 (file)
@@ -200,3 +200,20 @@ Result AM_GetTitleProductCode(u8 mediatype, u64 titleID, char* productCode)
 
        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];
+}
index 6a02044572ca8566759407c98854144c69158f20..cd48f6f7a18b90a627e9e047c7b100a37ee1dff7 100644 (file)
@@ -458,11 +458,60 @@ FSUSER_DeleteDirectory(Handle     *handle,
        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
-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