rg_storage: Removed spurious logging

This commit is contained in:
Alex Duchesne 2023-03-31 16:06:00 -04:00
parent b948708c14
commit e54de0e06b
2 changed files with 30 additions and 49 deletions

View File

@ -508,7 +508,7 @@ void rg_gui_draw_status_bars(void)
(int)round(stats.totalFPS),
(int)round(stats.busyPercent));
if (app->romPath && strlen(app->romPath) > max_len)
if (app->romPath && strlen(app->romPath) > max_len - 1)
snprintf(footer, max_len, "...%s", app->romPath + (strlen(app->romPath) - (max_len - 4)));
else if (app->romPath)
snprintf(footer, max_len, "%s", app->romPath);
@ -720,7 +720,7 @@ int rg_gui_dialog(const char *title, const rg_gui_option_t *options_const, int s
if (option->update_cb)
option->update_cb(option, RG_DIALOG_INIT);
}
RG_LOGI("text_buffer usage = %d\n", (intptr_t)(text_buffer_ptr - text_buffer));
RG_LOGD("text_buffer usage = %d\n", (intptr_t)(text_buffer_ptr - text_buffer));
rg_gui_draw_status_bars();
rg_gui_draw_dialog(title, options, sel);

View File

@ -202,64 +202,49 @@ bool rg_storage_mkdir(const char *dir)
{
RG_ASSERT(dir, "Bad param");
char temp[RG_PATH_MAX + 1];
int ret = mkdir(dir, 0777);
if (mkdir(dir, 0777) == 0)
return true;
if (ret == -1)
// FIXME: Might want to stat to see if it's a dir
if (errno == EEXIST)
return true;
// Possibly missing some parents, try creating them
char *temp = strdup(dir);
for (char *p = temp + strlen(RG_STORAGE_ROOT) + 1; *p; p++)
{
if (errno == EEXIST)
return true;
strncpy(temp, dir, RG_PATH_MAX);
for (char *p = temp + strlen(RG_STORAGE_ROOT) + 1; *p; p++)
if (*p == '/')
{
if (*p == '/')
*p = 0;
if (strlen(temp) > 0)
{
*p = 0;
if (strlen(temp) > 0)
{
RG_LOGI("Creating %s\n", temp);
mkdir(temp, 0777);
}
*p = '/';
while (*(p + 1) == '/')
p++;
mkdir(temp, 0777);
}
*p = '/';
while (*(p + 1) == '/')
p++;
}
ret = mkdir(temp, 0777);
}
free(temp);
if (ret == 0)
{
RG_LOGI("Folder created %s\n", dir);
}
// Finally try again
if (mkdir(dir, 0777) == 0)
return true;
return (ret == 0);
return false;
}
bool rg_storage_delete(const char *path)
{
RG_ASSERT(path, "Bad param");
DIR *dir;
if (unlink(path) == 0)
{
RG_LOGI("Deleted file %s\n", path);
// errno has proven to be somewhat unreliable across our targets
// let's use a bruteforce approach...
if (unlink(path) == 0 || rmdir(path) == 0)
return true;
}
else if (errno == ENOENT)
{
// The path already doesn't exist!
return true;
}
else if (rmdir(path) == 0)
{
RG_LOGI("Deleted empty folder %s\n", path);
return true;
}
else if ((dir = opendir(path)))
DIR *dir = opendir(path);
if (dir)
{
char pathbuf[128]; // Smaller than RG_PATH_MAX to prevent issues due to lazy recursion...
struct dirent *ent;
@ -272,11 +257,7 @@ bool rg_storage_delete(const char *path)
rg_storage_delete(pathbuf);
}
closedir(dir);
if (rmdir(path) == 0)
{
RG_LOGI("Deleted folder %s\n", path);
return true;
}
return rmdir(path) == 0;
}
return false;