1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-05 19:51:45 +00:00

[stage2] Add dump_to_file

This commit is contained in:
TuxSH 2018-05-14 00:03:05 +02:00
parent 8df624a10d
commit bc7369b5d1
3 changed files with 13 additions and 0 deletions

View file

@ -13,3 +13,14 @@ size_t read_from_file(void *dst, size_t dst_size, const char *filename) {
return sz; return sz;
} }
} }
size_t dump_to_file(const void *src, size_t src_size, const char *filename) {
FILE *file = fopen(filename, "wb+");
if (file == NULL) {
return 0;
} else {
size_t sz = fwrite(src, 1, src_size, file);
fclose(file);
return sz;
}
}

View file

@ -5,5 +5,6 @@
#include "sdmmc.h" #include "sdmmc.h"
size_t read_from_file(void *dst, size_t dst_size, const char *filename); size_t read_from_file(void *dst, size_t dst_size, const char *filename);
size_t dump_to_file(const void *src, size_t src_size, const char *filename);
#endif #endif

View file

@ -44,6 +44,7 @@ static int mmc_partition_initialize(device_partition_t *devpart) {
if (mmcpart->mmc == &g_sd_mmc && !g_sd_mmc_initialized) { if (mmcpart->mmc == &g_sd_mmc && !g_sd_mmc_initialized) {
int rc = sdmmc_init(mmcpart->mmc, mmcpart->controller); int rc = sdmmc_init(mmcpart->mmc, mmcpart->controller);
if (rc == 0) { if (rc == 0) {
sdmmc_set_write_enable(mmcpart->mmc, SDMMC_WRITE_ENABLED);
g_sd_mmc_initialized = true; g_sd_mmc_initialized = true;
} }
return rc; return rc;