Kaynağa Gözat

Create save and sram dirs when needed

master
Nathaniel Walizer 10 ay önce
ebeveyn
işleme
6eedb3f46b
4 değiştirilmiş dosya ile 39 ekleme ve 1 silme
  1. +3
    -1
      src/compat.c
  2. +8
    -0
      src/compat.h
  3. +24
    -0
      src/compat_impl.h
  4. +4
    -0
      src/save.c

+ 3
- 1
src/compat.c Dosyayı Görüntüle

@@ -1,4 +1,6 @@
#include "compat.h"
#include <stdio.h>

#include "compat_impl.h"


#if !defined (__unix__) && !(defined (__APPLE__) && defined (__MACH__))


+ 8
- 0
src/compat.h Dosyayı Görüntüle

@@ -15,4 +15,12 @@ ssize_t getline(char **restrict lineptr, size_t *restrict n,

#endif


int mkdir_impl(const char*);

static inline int mkdir(const char* dir) {
return mkdir_impl(dir);
}


#endif // NESE_COMPAT_H_

+ 24
- 0
src/compat_impl.h Dosyayı Görüntüle

@@ -0,0 +1,24 @@
#ifndef NESE_COMPAT_IMPL_H_
#define NESE_COMPAT_IMPL_H_


#ifdef _WIN32

#include <direct.h>

int mkdir_impl(const char* dir) {
return _mkdir(dir);
}

#else // !_WIN32

#include <sys/stat.h>

int mkdir_impl(const char* dir) {
return mkdir(dir, 0777);
}

#endif // _WIN32


#endif // NESE_COMPAT_IMPL_H_

+ 4
- 0
src/save.c Dosyayı Görüntüle

@@ -5,6 +5,7 @@
#include "file.h"
#include "mapper.h"
#include "filemap.h"
#include "compat.h"


/* SRAM */
@@ -44,6 +45,7 @@ int save_sram(const nes_cart* cart, const char* cart_filename) {
cart->mapper->sram(cart->map_data) : NULL;

if (sram_size > 0 && NULL != sram) {
mkdir("sram");
char sram_filename[FILENAME_MAX] = {0};
make_sram_filename(sram_filename, FILENAME_MAX - 1,
cart_filename);
@@ -91,6 +93,8 @@ int load_state(nes* sys, const char* cart_filename) {
int save_state(const nes* sys, const char* cart_filename) {
int size = -1;

mkdir("save");

char state_filename[FILENAME_MAX] = {0};
make_state_filename(state_filename, FILENAME_MAX - 1,
cart_filename);


Yükleniyor…
İptal
Kaydet