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:
Pk11
2021-05-26 05:47:51 -05:00
committed by GitHub
parent bfecbc86af
commit baa14561eb
11 changed files with 150 additions and 110 deletions
+11
View File
@@ -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;
}