mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Add safety checks for low SD card space (#90)
* Some attempt. * Enable some-safety-freespace-work nightlies * Upload elf with nightly * *Derp fixes.* * Bye Bye testing things. * Revert "Upload elf with nightly" This reverts commit 303968cd78e466a3fcc010915565d8265acaa76a. * Add safety checks to fcopy Co-authored-by: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
|
||||
#include "files.hpp"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
FS_Path getPathInfo(const char *path, FS_ArchiveID *archive) {
|
||||
*archive = ARCHIVE_SDMC;
|
||||
@@ -127,4 +129,13 @@ Result removeDirRecursive(const char *path) {
|
||||
FSUSER_CloseArchive(archive);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Code borrowed from GodMode9i:
|
||||
https://github.com/DS-Homebrew/GodMode9i/blob/d68ac105e68b4a1fc2c706a08c7a394255c325c2/arm9/source/driveOperations.cpp#L166-L170
|
||||
*/
|
||||
u64 getAvailableSpace() {
|
||||
struct statvfs st;
|
||||
statvfs("sdmc:/", &st);
|
||||
return (u64)st.f_bsize * (u64)st.f_bavail;
|
||||
}
|
||||
Reference in New Issue
Block a user