mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-02 09:35:20 -05:00
Make use of "ensure_directory" function (#1765)
This commit is contained in:
parent
409242507c
commit
58307aee9c
@ -40,7 +40,7 @@ using namespace portapack;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
fs::path get_settings_path(const std::string& app_name) {
|
fs::path get_settings_path(const std::string& app_name) {
|
||||||
return fs::path{u"/SETTINGS"} / app_name + u".ini";
|
return fs::path{SETTINGS_DIR} / app_name + u".ini";
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ bool save_settings(std::string_view store_name, const SettingBindings& bindings)
|
|||||||
File f;
|
File f;
|
||||||
auto path = get_settings_path(std::string{store_name});
|
auto path = get_settings_path(std::string{store_name});
|
||||||
|
|
||||||
make_new_directory(SETTINGS_DIR);
|
ensure_directory(SETTINGS_DIR);
|
||||||
auto error = f.create(path);
|
auto error = f.create(path);
|
||||||
if (error)
|
if (error)
|
||||||
return false;
|
return false;
|
||||||
|
@ -54,8 +54,6 @@
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
#define RECON_CFG_FILE u"SETTINGS/recon.cfg"
|
|
||||||
|
|
||||||
enum class recon_mode : uint8_t {
|
enum class recon_mode : uint8_t {
|
||||||
Recon,
|
Recon,
|
||||||
Scanner,
|
Scanner,
|
||||||
|
@ -275,7 +275,7 @@ bool memory_dump(uint32_t* addr_start, uint32_t num_words, bool stack_flag) {
|
|||||||
int n{0};
|
int n{0};
|
||||||
bool data_found{false};
|
bool data_found{false};
|
||||||
|
|
||||||
make_new_directory(debug_dir);
|
ensure_directory(debug_dir);
|
||||||
filename = next_filename_matching_pattern(debug_dir + "/" + (stack_flag ? "STACK" : "MEMORY") + "_DUMP_????.TXT");
|
filename = next_filename_matching_pattern(debug_dir + "/" + (stack_flag ? "STACK" : "MEMORY") + "_DUMP_????.TXT");
|
||||||
error = filename.empty();
|
error = filename.empty();
|
||||||
if (!error)
|
if (!error)
|
||||||
|
@ -177,7 +177,7 @@ enum class PortaPackModel {
|
|||||||
static bool save_config(int8_t value) {
|
static bool save_config(int8_t value) {
|
||||||
persistent_memory::set_config_cpld(value);
|
persistent_memory::set_config_cpld(value);
|
||||||
if (sd_card::status() == sd_card::Status::Mounted) {
|
if (sd_card::status() == sd_card::Status::Mounted) {
|
||||||
make_new_directory("/hardware");
|
ensure_directory("/hardware");
|
||||||
File file;
|
File file;
|
||||||
auto sucess = file.create("/hardware/settings.txt");
|
auto sucess = file.create("/hardware/settings.txt");
|
||||||
if (!sucess.is_valid()) {
|
if (!sucess.is_valid()) {
|
||||||
|
@ -570,7 +570,7 @@ void SystemStatusView::rtc_battery_workaround() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
make_new_directory(SETTINGS_DIR);
|
ensure_directory(SETTINGS_DIR);
|
||||||
make_new_file(DATE_FILEFLAG);
|
make_new_file(DATE_FILEFLAG);
|
||||||
|
|
||||||
year = 1980;
|
year = 1980;
|
||||||
|
@ -963,7 +963,7 @@ bool should_use_sdcard_for_pmem() {
|
|||||||
int save_persistent_settings_to_file() {
|
int save_persistent_settings_to_file() {
|
||||||
File outfile;
|
File outfile;
|
||||||
|
|
||||||
make_new_directory(SETTINGS_DIR);
|
ensure_directory(SETTINGS_DIR);
|
||||||
auto error = outfile.create(PMEM_SETTING_FILE);
|
auto error = outfile.create(PMEM_SETTING_FILE);
|
||||||
if (error)
|
if (error)
|
||||||
return false;
|
return false;
|
||||||
@ -996,7 +996,7 @@ bool debug_dump() {
|
|||||||
std::filesystem::path filename{};
|
std::filesystem::path filename{};
|
||||||
File pmem_dump_file{};
|
File pmem_dump_file{};
|
||||||
// create new dump file name and DEBUG directory
|
// 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");
|
filename = next_filename_matching_pattern(debug_dir + "/DEBUG_DUMP_????.TXT");
|
||||||
if (filename.empty()) {
|
if (filename.empty()) {
|
||||||
painter.draw_string({0, 320 - 16}, ui::Styles::red, "COULD NOT GET DUMP NAME !");
|
painter.draw_string({0, 320 - 16}, ui::Styles::red, "COULD NOT GET DUMP NAME !");
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
#include "serializer.hpp"
|
#include "serializer.hpp"
|
||||||
#include "volume.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"
|
#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_SETTING_FILE u"/SETTINGS/pmem_settings"
|
||||||
|
|
||||||
#define PMEM_SIZE_BYTES 256 // total amount of pmem space in bytes, including checksum
|
#define PMEM_SIZE_BYTES 256 // total amount of pmem space in bytes, including checksum
|
||||||
|
@ -53,7 +53,6 @@ class UnTar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool create_dir(char* pathname) {
|
static bool create_dir(char* pathname) {
|
||||||
char* p;
|
|
||||||
std::filesystem::filesystem_error r;
|
std::filesystem::filesystem_error r;
|
||||||
|
|
||||||
if (!isValidName(pathname)) return false;
|
if (!isValidName(pathname)) return false;
|
||||||
@ -65,18 +64,7 @@ class UnTar {
|
|||||||
std::string dirnameStr = u'/' + pathname;
|
std::string dirnameStr = u'/' + pathname;
|
||||||
std::filesystem::path dirname = dirnameStr;
|
std::filesystem::path dirname = dirnameStr;
|
||||||
|
|
||||||
r = make_new_directory(dirname);
|
r = ensure_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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (r.ok());
|
return (r.ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user