mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-22 12:35:11 +00:00
parent
06dfb7e803
commit
8ab97a959c
8 changed files with 35 additions and 10 deletions
|
@ -79,6 +79,7 @@ endif()
|
|||
|
||||
set(ENGINE_SOURCES
|
||||
src/log.cpp
|
||||
src/fileutils.cpp
|
||||
|
||||
extern/Nuked-OPN2/ym3438.c
|
||||
extern/opm/opm.c
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "instrument.h"
|
||||
#include "safeReader.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../fileutils.h"
|
||||
#include "../audio/sdl.h"
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
|
@ -2260,7 +2261,7 @@ void DivEngine::notifyWaveChange(int wave) {
|
|||
|
||||
bool DivEngine::saveConf() {
|
||||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=fopen(configFile.c_str(),"wb");
|
||||
FILE* f=ps_fopen(configFile.c_str(),"wb");
|
||||
if (f==NULL) {
|
||||
logW("could not write config file! %s\n",strerror(errno));
|
||||
return false;
|
||||
|
@ -2280,7 +2281,7 @@ bool DivEngine::saveConf() {
|
|||
bool DivEngine::loadConf() {
|
||||
char line[4096];
|
||||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=fopen(configFile.c_str(),"rb");
|
||||
FILE* f=ps_fopen(configFile.c_str(),"rb");
|
||||
if (f==NULL) {
|
||||
logI("creating default config.\n");
|
||||
return saveConf();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "engine.h"
|
||||
#include "instrument.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../fileutils.h"
|
||||
|
||||
void DivInstrument::putInsData(SafeWriter* w) {
|
||||
w->write("INST",4);
|
||||
|
@ -159,7 +160,7 @@ bool DivInstrument::save(const char* path) {
|
|||
|
||||
putInsData(w);
|
||||
|
||||
FILE* outFile=fopen(path,"wb");
|
||||
FILE* outFile=ps_fopen(path,"wb");
|
||||
if (outFile==NULL) {
|
||||
logE("could not save instrument: %s!\n",strerror(errno));
|
||||
w->finish();
|
||||
|
@ -171,4 +172,4 @@ bool DivInstrument::save(const char* path) {
|
|||
fclose(outFile);
|
||||
w->finish();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "engine.h"
|
||||
#include "wavetable.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../fileutils.h"
|
||||
|
||||
void DivWavetable::putWaveData(SafeWriter* w) {
|
||||
w->write("WAVE",4);
|
||||
|
@ -30,7 +31,7 @@ bool DivWavetable::save(const char* path) {
|
|||
|
||||
putWaveData(w);
|
||||
|
||||
FILE* outFile=fopen(path,"wb");
|
||||
FILE* outFile=ps_fopen(path,"wb");
|
||||
if (outFile==NULL) {
|
||||
logE("could not save wavetable: %s!\n",strerror(errno));
|
||||
w->finish();
|
||||
|
|
12
src/fileutils.cpp
Normal file
12
src/fileutils.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "fileutils.h"
|
||||
#ifdef _WIN32
|
||||
#include "utfutils.h"
|
||||
#endif
|
||||
|
||||
FILE* ps_fopen(const char* path, const char* mode) {
|
||||
#ifdef _WIN32
|
||||
return _wfopen(utf8To16(path).c_str(),utf8To16(mode).c_str());
|
||||
#else
|
||||
return fopen(path,mode);
|
||||
#endif
|
||||
}
|
7
src/fileutils.h
Normal file
7
src/fileutils.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef _FILEUTILS_H
|
||||
#define _FILEUTILS_H
|
||||
#include <stdio.h>
|
||||
|
||||
FILE* ps_fopen(const char* path, const char* mode);
|
||||
|
||||
#endif
|
|
@ -8,6 +8,7 @@
|
|||
#include "fonts.h"
|
||||
#include "icon.h"
|
||||
#include "../ta-log.h"
|
||||
#include "../fileutils.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl.h"
|
||||
#include "imgui_impl_sdlrenderer.h"
|
||||
|
@ -251,7 +252,7 @@ DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,24 Size=1280,800 Split=Y
|
|||
|
||||
void FurnaceGUI::prepareLayout() {
|
||||
FILE* check;
|
||||
check=fopen(finalLayoutPath,"r");
|
||||
check=ps_fopen(finalLayoutPath,"r");
|
||||
if (check!=NULL) {
|
||||
fclose(check);
|
||||
return;
|
||||
|
@ -259,7 +260,7 @@ void FurnaceGUI::prepareLayout() {
|
|||
|
||||
// copy initial layout
|
||||
logI("loading default layout.\n");
|
||||
check=fopen(finalLayoutPath,"w");
|
||||
check=ps_fopen(finalLayoutPath,"w");
|
||||
if (check==NULL) {
|
||||
logW("could not write default layout!\n");
|
||||
return;
|
||||
|
@ -3133,7 +3134,7 @@ int FurnaceGUI::save(String path) {
|
|||
lastError=e->getLastError();
|
||||
return 3;
|
||||
}
|
||||
FILE* outFile=fopen(path.c_str(),"wb");
|
||||
FILE* outFile=ps_fopen(path.c_str(),"wb");
|
||||
if (outFile==NULL) {
|
||||
lastError=strerror(errno);
|
||||
w->finish();
|
||||
|
@ -3217,7 +3218,7 @@ int FurnaceGUI::save(String path) {
|
|||
int FurnaceGUI::load(String path) {
|
||||
if (!path.empty()) {
|
||||
logI("loading module...\n");
|
||||
FILE* f=fopen(path.c_str(),"rb");
|
||||
FILE* f=ps_fopen(path.c_str(),"rb");
|
||||
if (f==NULL) {
|
||||
perror("error");
|
||||
lastError=strerror(errno);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include "ta-log.h"
|
||||
#include "fileutils.h"
|
||||
#include "engine/engine.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -249,7 +250,7 @@ int main(int argc, char** argv) {
|
|||
logI("Furnace version " DIV_VERSION ".\n");
|
||||
if (!fileName.empty()) {
|
||||
logI("loading module...\n");
|
||||
FILE* f=fopen(fileName.c_str(),"rb");
|
||||
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
||||
if (f==NULL) {
|
||||
perror("error");
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue