Skip to content

Commit

Permalink
revert implementation of mkst#91
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitl committed May 29, 2024
1 parent 2a46bff commit 0277640
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
23 changes: 0 additions & 23 deletions src/pc/pc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#include "configfile.h"

#include "compat.h"
#include <sys/stat.h>
#include <sys/types.h>

int mkdir(const char *pathname, mode_t mode);

#define CONFIG_FILE "config/sm64/sm64config.txt"

Expand Down Expand Up @@ -134,25 +130,7 @@ static void on_anim_frame(double time) {
}
#endif

//https://stackoverflow.com/questions/21236508/to-create-all-needed-folders-with-fopen
const char pathSeparator = '/';

// Given a file path, create all constituent directories if missing
void create_file_path_dirs(char *file_path) {
char *dir_path = (char *) malloc(strlen(file_path) + 1);
char *next_sep = strchr(file_path, pathSeparator);
while (next_sep != NULL) {
int dir_path_len = next_sep - file_path;
memcpy(dir_path, file_path, dir_path_len);
dir_path[dir_path_len] = '\0';
mkdir(dir_path, S_IRWXU|S_IRWXG|S_IROTH);
next_sep = strchr(next_sep + 1, pathSeparator);
}
free(dir_path);
}

static void save_config(void) {
create_file_path_dirs(CONFIG_FILE);
configfile_save(CONFIG_FILE);
}

Expand All @@ -165,7 +143,6 @@ void main_func(void) {
main_pool_init(pool, pool + sizeof(pool));
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);

create_file_path_dirs(CONFIG_FILE);
configfile_load(CONFIG_FILE);
atexit(save_config);

Expand Down
11 changes: 0 additions & 11 deletions src/pc/ultra_reimplementation.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "lib/src/libultra_internal.h"
Expand All @@ -8,15 +7,8 @@
#include <emscripten.h>
#endif

#include <sys/stat.h>
#include <sys/types.h>

int mkdir(const char *pathname, mode_t mode);

#define SAVE_FILE "config/sm64/sm64_save_file.bin"

extern void create_file_path_dirs(char *file_path);

extern OSMgrArgs piMgrArgs;

u64 osClockRate = 62500000;
Expand Down Expand Up @@ -156,8 +148,6 @@ s32 osEepromLongRead(UNUSED OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes)
ret = 0;
}
#else
create_file_path_dirs(SAVE_FILE);

FILE *fp = fopen(SAVE_FILE, "rb");
if (fp == NULL) {
return -1;
Expand Down Expand Up @@ -188,7 +178,6 @@ s32 osEepromLongWrite(UNUSED OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes
}, content);
s32 ret = 0;
#else
create_file_path_dirs(SAVE_FILE);
FILE* fp = fopen(SAVE_FILE, "wb");
if (fp == NULL) {
return -1;
Expand Down

0 comments on commit 0277640

Please sign in to comment.