linux compat
This commit is contained in:
20
lib/cart.c
20
lib/cart.c
@ -287,6 +287,7 @@ bool cart_load(char *cart) {
|
||||
if(ctx.battery) {
|
||||
cart_battery_load();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -493,11 +494,21 @@ void cart_write(u16 address, u8 value){
|
||||
}
|
||||
|
||||
bool cart_battery_load(){
|
||||
#ifdef __windows__
|
||||
char *filename = strrchr(ctx.filename, '\\');
|
||||
#else
|
||||
char *filename = strrchr(ctx.filename, '/');
|
||||
#endif
|
||||
filename++;
|
||||
char fn[1048];
|
||||
#ifdef __windows__
|
||||
char *profile = getenv("USERPROFILE");
|
||||
sprintf(fn, "%s/Documents/gbemu/saves/%s.battery", profile, filename);
|
||||
#else
|
||||
char *profile = getenv("HOME");
|
||||
sprintf(fn, "%s/.config/gbemu/saves/%s.battery", profile, filename);
|
||||
#endif
|
||||
printf("loading %s\n", fn);
|
||||
FILE *fp = fopen(fn, "rb");
|
||||
|
||||
if(!fp) {
|
||||
@ -510,11 +521,20 @@ bool cart_battery_load(){
|
||||
}
|
||||
|
||||
bool cart_battery_save(){
|
||||
#ifdef __windows__
|
||||
char *filename = strrchr(ctx.filename, '\\');
|
||||
#else
|
||||
char *filename = strrchr(ctx.filename, '/');
|
||||
#endif
|
||||
filename++;
|
||||
char fn[1048];
|
||||
#ifdef __windows__
|
||||
char *profile = getenv("USERPROFILE");
|
||||
sprintf(fn, "%s/Documents/gbemu/saves/%s.battery", profile, filename);
|
||||
#else
|
||||
char *profile = getenv("HOME");
|
||||
sprintf(fn, "%s/.config/gbemu/saves/%s.battery", profile, filename);
|
||||
#endif
|
||||
FILE *fp = fopen(fn, "wb");
|
||||
|
||||
if(!fp) {
|
||||
|
Reference in New Issue
Block a user