diff --git a/libctru/include/3ds/services/fs.h b/libctru/include/3ds/services/fs.h index 2f7b4dd..acac55a 100644 --- a/libctru/include/3ds/services/fs.h +++ b/libctru/include/3ds/services/fs.h @@ -150,6 +150,7 @@ Result FSUSER_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clust 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_GetMediaType(Handle *handle, u8* mediatype); Result FSFILE_Close(Handle handle); Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size); diff --git a/libctru/source/services/fs.c b/libctru/source/services/fs.c index 157583e..8043fcd 100644 --- a/libctru/source/services/fs.c +++ b/libctru/source/services/fs.c @@ -1051,6 +1051,49 @@ FSUSER_IsSdmcDetected(Handle *handle, return cmdbuf[1]; } +/*! Close an open file + * + * @param[in] handle fs:USER handle + * @param[out] mediatype Output curent process mediatype + * + * @returns error + * + * @internal + * + * #### Request + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code [0x08680000] + * + * #### Response + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code + * 1 | Result code + */ +Result +FSUSER_GetMediaType(Handle *handle, + u8* mediatype) +{ + if(!handle) + handle = &fsuHandle; + + u32* cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x08680000; + + Result ret = 0; + if((ret = svcSendSyncRequest(*handle))) + return ret; + + if(mediatype) + *mediatype = cmdbuf[2]; + + return cmdbuf[1]; +} + /*! Check if SD card is writable * * @param[in] handle fs:USER handle