parent
06dfb7e803
commit
8ab97a959c
|
@ -79,6 +79,7 @@ endif()
|
||||||
|
|
||||||
set(ENGINE_SOURCES
|
set(ENGINE_SOURCES
|
||||||
src/log.cpp
|
src/log.cpp
|
||||||
|
src/fileutils.cpp
|
||||||
|
|
||||||
extern/Nuked-OPN2/ym3438.c
|
extern/Nuked-OPN2/ym3438.c
|
||||||
extern/opm/opm.c
|
extern/opm/opm.c
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
#include "safeReader.h"
|
#include "safeReader.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
#include "../fileutils.h"
|
||||||
#include "../audio/sdl.h"
|
#include "../audio/sdl.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -2260,7 +2261,7 @@ void DivEngine::notifyWaveChange(int wave) {
|
||||||
|
|
||||||
bool DivEngine::saveConf() {
|
bool DivEngine::saveConf() {
|
||||||
configFile=configPath+String(CONFIG_FILE);
|
configFile=configPath+String(CONFIG_FILE);
|
||||||
FILE* f=fopen(configFile.c_str(),"wb");
|
FILE* f=ps_fopen(configFile.c_str(),"wb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
logW("could not write config file! %s\n",strerror(errno));
|
logW("could not write config file! %s\n",strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
|
@ -2280,7 +2281,7 @@ bool DivEngine::saveConf() {
|
||||||
bool DivEngine::loadConf() {
|
bool DivEngine::loadConf() {
|
||||||
char line[4096];
|
char line[4096];
|
||||||
configFile=configPath+String(CONFIG_FILE);
|
configFile=configPath+String(CONFIG_FILE);
|
||||||
FILE* f=fopen(configFile.c_str(),"rb");
|
FILE* f=ps_fopen(configFile.c_str(),"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
logI("creating default config.\n");
|
logI("creating default config.\n");
|
||||||
return saveConf();
|
return saveConf();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
#include "../fileutils.h"
|
||||||
|
|
||||||
void DivInstrument::putInsData(SafeWriter* w) {
|
void DivInstrument::putInsData(SafeWriter* w) {
|
||||||
w->write("INST",4);
|
w->write("INST",4);
|
||||||
|
@ -159,7 +160,7 @@ bool DivInstrument::save(const char* path) {
|
||||||
|
|
||||||
putInsData(w);
|
putInsData(w);
|
||||||
|
|
||||||
FILE* outFile=fopen(path,"wb");
|
FILE* outFile=ps_fopen(path,"wb");
|
||||||
if (outFile==NULL) {
|
if (outFile==NULL) {
|
||||||
logE("could not save instrument: %s!\n",strerror(errno));
|
logE("could not save instrument: %s!\n",strerror(errno));
|
||||||
w->finish();
|
w->finish();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "wavetable.h"
|
#include "wavetable.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
#include "../fileutils.h"
|
||||||
|
|
||||||
void DivWavetable::putWaveData(SafeWriter* w) {
|
void DivWavetable::putWaveData(SafeWriter* w) {
|
||||||
w->write("WAVE",4);
|
w->write("WAVE",4);
|
||||||
|
@ -30,7 +31,7 @@ bool DivWavetable::save(const char* path) {
|
||||||
|
|
||||||
putWaveData(w);
|
putWaveData(w);
|
||||||
|
|
||||||
FILE* outFile=fopen(path,"wb");
|
FILE* outFile=ps_fopen(path,"wb");
|
||||||
if (outFile==NULL) {
|
if (outFile==NULL) {
|
||||||
logE("could not save wavetable: %s!\n",strerror(errno));
|
logE("could not save wavetable: %s!\n",strerror(errno));
|
||||||
w->finish();
|
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 "fonts.h"
|
||||||
#include "icon.h"
|
#include "icon.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
#include "../fileutils.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl.h"
|
#include "imgui_impl_sdl.h"
|
||||||
#include "imgui_impl_sdlrenderer.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() {
|
void FurnaceGUI::prepareLayout() {
|
||||||
FILE* check;
|
FILE* check;
|
||||||
check=fopen(finalLayoutPath,"r");
|
check=ps_fopen(finalLayoutPath,"r");
|
||||||
if (check!=NULL) {
|
if (check!=NULL) {
|
||||||
fclose(check);
|
fclose(check);
|
||||||
return;
|
return;
|
||||||
|
@ -259,7 +260,7 @@ void FurnaceGUI::prepareLayout() {
|
||||||
|
|
||||||
// copy initial layout
|
// copy initial layout
|
||||||
logI("loading default layout.\n");
|
logI("loading default layout.\n");
|
||||||
check=fopen(finalLayoutPath,"w");
|
check=ps_fopen(finalLayoutPath,"w");
|
||||||
if (check==NULL) {
|
if (check==NULL) {
|
||||||
logW("could not write default layout!\n");
|
logW("could not write default layout!\n");
|
||||||
return;
|
return;
|
||||||
|
@ -3133,7 +3134,7 @@ int FurnaceGUI::save(String path) {
|
||||||
lastError=e->getLastError();
|
lastError=e->getLastError();
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
FILE* outFile=fopen(path.c_str(),"wb");
|
FILE* outFile=ps_fopen(path.c_str(),"wb");
|
||||||
if (outFile==NULL) {
|
if (outFile==NULL) {
|
||||||
lastError=strerror(errno);
|
lastError=strerror(errno);
|
||||||
w->finish();
|
w->finish();
|
||||||
|
@ -3217,7 +3218,7 @@ int FurnaceGUI::save(String path) {
|
||||||
int FurnaceGUI::load(String path) {
|
int FurnaceGUI::load(String path) {
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
logI("loading module...\n");
|
logI("loading module...\n");
|
||||||
FILE* f=fopen(path.c_str(),"rb");
|
FILE* f=ps_fopen(path.c_str(),"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
perror("error");
|
perror("error");
|
||||||
lastError=strerror(errno);
|
lastError=strerror(errno);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "ta-log.h"
|
#include "ta-log.h"
|
||||||
|
#include "fileutils.h"
|
||||||
#include "engine/engine.h"
|
#include "engine/engine.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -249,7 +250,7 @@ int main(int argc, char** argv) {
|
||||||
logI("Furnace version " DIV_VERSION ".\n");
|
logI("Furnace version " DIV_VERSION ".\n");
|
||||||
if (!fileName.empty()) {
|
if (!fileName.empty()) {
|
||||||
logI("loading module...\n");
|
logI("loading module...\n");
|
||||||
FILE* f=fopen(fileName.c_str(),"rb");
|
FILE* f=ps_fopen(fileName.c_str(),"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
perror("error");
|
perror("error");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue