diff --git a/libctru/include/3ds/FS.h b/libctru/include/3ds/FS.h index 5cf9945..d26920f 100644 --- a/libctru/include/3ds/FS.h +++ b/libctru/include/3ds/FS.h @@ -139,6 +139,8 @@ Result FSUSER_CloseArchive(Handle* handle, FS_archive* archive); 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_IsSdmcDetected(Handle *handle); +Result FSUSER_IsSdmcWritable(Handle *handle); 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 cdd2f31..4216e85 100644 --- a/libctru/source/services/fs.c +++ b/libctru/source/services/fs.c @@ -1,8 +1,5 @@ #include -#include <3ds/types.h> -#include <3ds/FS.h> -#include <3ds/srv.h> -#include <3ds/svc.h> +#include <3ds.h> /*! @internal * @@ -609,6 +606,82 @@ FSUSER_CloseArchive(Handle *handle, return cmdbuf[1]; } +/*! Check if SD card is detected + * + * @param[in] handle fs:USER handle + * + * @returns error + * + * @internal + * + * #### Request + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code [0x08170000] + * + * #### Response + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code + * 1 | Result code + */ +Result +FSUSER_IsSdmcDetected(Handle *handle) +{ + if(!handle) + handle = &fsuHandle; + + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x08170000; + + Result ret = 0; + if((ret = svcSendSyncRequest(*handle))) + return ret; + + return cmdbuf[1]; +} + +/*! Check if SD card is writable + * + * @param[in] handle fs:USER handle + * + * @returns error + * + * @internal + * + * #### Request + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code [0x08180000] + * + * #### Response + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code + * 1 | Result code + */ +Result +FSUSER_IsSdmcWritable(Handle *handle) +{ + if(!handle) + handle = &fsuHandle; + + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x08180000; + + Result ret = 0; + if((ret = svcSendSyncRequest(*handle))) + return ret; + + return cmdbuf[1]; +} + /*! Close an open file * * @param[in] handle Open file handle