Make use of "ensure_directory" function (#1765)

This commit is contained in:
Mark Thompson
2024-01-13 00:57:32 -06:00
committed by GitHub
parent 409242507c
commit 58307aee9c
8 changed files with 10 additions and 24 deletions

View File

@@ -963,7 +963,7 @@ bool should_use_sdcard_for_pmem() {
int save_persistent_settings_to_file() {
File outfile;
make_new_directory(SETTINGS_DIR);
ensure_directory(SETTINGS_DIR);
auto error = outfile.create(PMEM_SETTING_FILE);
if (error)
return false;
@@ -996,7 +996,7 @@ bool debug_dump() {
std::filesystem::path filename{};
File pmem_dump_file{};
// create new dump file name and DEBUG directory
make_new_directory(debug_dir);
ensure_directory(debug_dir);
filename = next_filename_matching_pattern(debug_dir + "/DEBUG_DUMP_????.TXT");
if (filename.empty()) {
painter.draw_string({0, 320 - 16}, ui::Styles::red, "COULD NOT GET DUMP NAME !");

View File

@@ -33,10 +33,10 @@
#include "serializer.hpp"
#include "volume.hpp"
// persistant memory from/to sdcard flag file
// persistent memory from/to sdcard flag file
#define PMEM_FILEFLAG u"/SETTINGS/PMEM_FILEFLAG"
// persistant memory from/to sdcard flag file
// persistent memory from/to sdcard flag file
#define PMEM_SETTING_FILE u"/SETTINGS/pmem_settings"
#define PMEM_SIZE_BYTES 256 // total amount of pmem space in bytes, including checksum

View File

@@ -53,7 +53,6 @@ class UnTar {
}
static bool create_dir(char* pathname) {
char* p;
std::filesystem::filesystem_error r;
if (!isValidName(pathname)) return false;
@@ -65,18 +64,7 @@ class UnTar {
std::string dirnameStr = u'/' + pathname;
std::filesystem::path dirname = dirnameStr;
r = make_new_directory(dirname);
if (!r.ok()) {
/* On failure, try creating parent directory. */
p = strrchr(pathname, '/');
if (p != NULL) {
*p = '\0';
create_dir(pathname);
*p = '/';
r = make_new_directory(dirname);
}
}
r = ensure_directory(dirname);
return (r.ok());
}