Reupload
This commit is contained in:
14
src/util.c
14
src/util.c
@@ -18,7 +18,6 @@
|
||||
#include "../include/otp.h"
|
||||
|
||||
// Global variables for preferences
|
||||
extern char current_pads_dir[512];
|
||||
static char default_pad_path[1024] = "";
|
||||
|
||||
void show_progress(uint64_t current, uint64_t total, time_t start_time) {
|
||||
@@ -355,7 +354,7 @@ int load_preferences(void) {
|
||||
}
|
||||
|
||||
// Find the first available pad to set as default
|
||||
DIR* dir = opendir(current_pads_dir);
|
||||
DIR* dir = opendir(get_current_pads_dir());
|
||||
if (dir) {
|
||||
struct dirent* entry;
|
||||
char first_pad_path[1024];
|
||||
@@ -364,9 +363,10 @@ int load_preferences(void) {
|
||||
while ((entry = readdir(dir)) != NULL && !found_pad) {
|
||||
if (strstr(entry->d_name, ".pad") && strlen(entry->d_name) == 68) {
|
||||
// Found a pad file - construct full absolute path
|
||||
if (current_pads_dir[0] == '/') {
|
||||
const char* pads_dir = get_current_pads_dir();
|
||||
if (pads_dir[0] == '/') {
|
||||
// Already absolute path
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s", current_pads_dir, entry->d_name);
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s", pads_dir, entry->d_name);
|
||||
if (ret >= (int)sizeof(first_pad_path)) {
|
||||
// Path was truncated, skip this entry
|
||||
continue;
|
||||
@@ -375,14 +375,14 @@ int load_preferences(void) {
|
||||
// Relative path - make it absolute
|
||||
char current_dir[512];
|
||||
if (getcwd(current_dir, sizeof(current_dir))) {
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s/%s", current_dir, current_pads_dir, entry->d_name);
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s/%s", current_dir, pads_dir, entry->d_name);
|
||||
if (ret >= (int)sizeof(first_pad_path)) {
|
||||
// Path was truncated, skip this entry
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// Fallback to relative path
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s", current_pads_dir, entry->d_name);
|
||||
int ret = snprintf(first_pad_path, sizeof(first_pad_path), "%s/%s", pads_dir, entry->d_name);
|
||||
if (ret >= (int)sizeof(first_pad_path)) {
|
||||
// Path was truncated, skip this entry
|
||||
continue;
|
||||
@@ -641,7 +641,7 @@ void get_directory_display(const char* file_path, char* result, size_t result_si
|
||||
}
|
||||
|
||||
// Current working directory
|
||||
if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, current_pads_dir) == 0) {
|
||||
if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, get_current_pads_dir()) == 0) {
|
||||
strncpy(result, "pads", result_size - 1);
|
||||
result[result_size - 1] = '\0';
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user