]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add FSUSER_IsSdmcDetected() and FSUSER_IsSdmcWritable().
authormtheall <pigman46@gmail.com>
Tue, 26 Aug 2014 20:58:18 +0000 (15:58 -0500)
committermtheall <pigman46@gmail.com>
Tue, 26 Aug 2014 20:58:18 +0000 (15:58 -0500)
libctru/include/3ds/FS.h
libctru/source/services/fs.c

index 5cf9945f3597c453a5565d9997f9483605361e38..d26920f419e85543ea7052bcf93dab7ff5f20612 100644 (file)
@@ -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);
index cdd2f31a3f115752ce04f7530f2113ccbd4bff1a..4216e8525e0aee412877c93f84d54e935542ba74 100644 (file)
@@ -1,8 +1,5 @@
 #include <string.h>
-#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