Added some source-level configurability to the paths... hope didn't break anything ;)

This commit is contained in:
gigaherz
2008-06-27 16:27:15 +00:00
parent df88607015
commit 1bc3239f71
11 changed files with 63 additions and 29 deletions

View File

@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
nclude <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@@ -34,6 +34,8 @@
#include "interface.h"
#include "Linux.h"
#include "Paths.h"
static int needReset = 1;
int confret;
@@ -322,7 +324,7 @@ void UpdateMenuSlots(GtkMenuItem *menuitem, gpointer user_data) {
int i;
for (i=0; i<5; i++) {
sprintf(str, "sstates/%8.8X.%3.3d", ElfCRC, i);
sprintf(str, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, i);
Slots[i] = CheckState(str);
}
}
@@ -334,7 +336,7 @@ void States_Load(int num) {
efile = 2;
RunExecute(0);
sprintf (Text, "sstates/%8.8X.%3.3d", ElfCRC, num);
sprintf (Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, num);
ret = LoadState(Text);
/* if (ret == 0)
sprintf (Text, _("*PCSX2*: Loaded State %d"), num+1);
@@ -348,7 +350,7 @@ void States_Save(int num) {
char Text[256];
int ret;
sprintf (Text, "sstates/%8.8X.%3.3d", ElfCRC, num);
sprintf (Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, num);
ret = SaveState(Text);
if (ret == 0)
sprintf(Text, _("*PCSX2*: Saving State %d"), num+1);
@@ -394,7 +396,7 @@ void OnStates_LoadOther(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Ok,*Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), "sstates/");
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnLoadOther_Ok), NULL);
@@ -442,7 +444,7 @@ void OnStates_SaveOther(GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget *Ok,*Cancel;
FileSel = gtk_file_selection_new(_("Select State File"));
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), "sstates/");
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), SSTATES_DIR "/");
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnSaveOther_Ok), NULL);

View File

@@ -40,6 +40,8 @@
#include "PsxCommon.h"
#include "Linux.h"
#include "../Paths.h"
int UseGui = 1;
int needReset = 1;
int RunExe = 0;
@@ -205,7 +207,7 @@ int main(int argc, char *argv[]) {
if (UseGui) gtk_init(NULL, NULL);
memset(&Config, 0, sizeof(Config));
strcpy(Config.BiosDir, "bios/");
strcpy(Config.BiosDir, DEFAULT_BIOS_DIR);
strcpy(Config.PluginsDir, "plugins/");
Config.Patch = 1;
Config.Options = PCSX2_EEREC|PCSX2_VU0REC|PCSX2_VU1REC|PCSX2_COP2REC;
@@ -290,7 +292,7 @@ int main(int argc, char *argv[]) {
DIR *dir;
void InitLanguages() {
dir = opendir("Langs");
dir = opendir(LANGS_DIR);
}
char *GetLanguageNext() {
@@ -381,17 +383,17 @@ void KeyEvent(keyEvent* ev) {
}
int SysInit() {
mkdir("sstates", 0755);
mkdir("memcards", 0755);
mkdir(SSTATES_DIR, 0755);
mkdir(MEMCARDS_DIR, 0755);
#ifdef EMU_LOG
mkdir("logs", 0755);
mkdir(LOGS_DIR, 0755);
#ifdef PCSX2_DEVBUILD
if( g_TestRun.plogname != NULL )
emuLog = fopen(g_TestRun.plogname, "w");
if( emuLog == NULL )
emuLog = fopen("logs/emuLog.txt","wb");
emuLog = fopen(LOGS_DIR "/emuLog.txt","wb");
#endif
if( emuLog != NULL )

View File

@@ -39,6 +39,8 @@
#include "GS.h"
#include "Cache.h"
#include "Paths.h"
u32 dwSaveVersion = 0x7a300010;
u32 dwCurSaveStateVer = 0;
@@ -766,7 +768,7 @@ int LoadGSState(char *file)
f = gzopen(file, "rb");
if (f == NULL) {
sprintf(strfile, "sstates/%s", file);
sprintf(strfile, SSTATES_DIR "/%s", file);
// try prefixing with sstates
f = gzopen(strfile, "rb");
if( f == NULL ) {
@@ -892,7 +894,7 @@ void ProcessFKeys(int fkey, int shift)
assert(fkey >= 1 && fkey <= 12 );
switch(fkey) {
case 1:
sprintf(Text, "sstates/%8.8X.%3.3d", ElfCRC, StatesC);
sprintf(Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
ret = SaveState(Text);
break;
case 2:
@@ -902,12 +904,12 @@ void ProcessFKeys(int fkey, int shift)
StatesC = (StatesC+1)%NUM_STATES;
SysPrintf("*PCSX2*: Selected State %ld\n", StatesC);
if( GSchangeSaveState != NULL ) {
sprintf(Text, "sstates/%8.8X.%3.3d", ElfCRC, StatesC);
sprintf(Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
GSchangeSaveState(StatesC, Text);
}
break;
case 3:
sprintf (Text, "sstates/%8.8X.%3.3d", ElfCRC, StatesC);
sprintf (Text, SSTATES_DIR "/%8.8X.%3.3d", ElfCRC, StatesC);
ret = LoadState(Text);
break;
@@ -992,10 +994,10 @@ void ProcessFKeys(int fkey, int shift)
tok = strtok(NULL, " ");
if( tok != NULL ) strcat(name, tok);
sprintf(Text, "sstates/%s.%d.gs", name, StatesC);
sprintf(Text, SSTATES_DIR "/%s.%d.gs", name, StatesC);
}
else
sprintf(Text, "sstates/%8.8X.%d.gs", ElfCRC, StatesC);
sprintf(Text, SSTATES_DIR "/%8.8X.%d.gs", ElfCRC, StatesC);
SaveGSState(Text);
}

View File

@@ -24,6 +24,8 @@
#include "PsxCommon.h"
#include "Paths.h"
#ifdef _WIN32
#include "windows/cheats/cheats.h"
#endif
@@ -497,9 +499,9 @@ void inifile_read( char * name )
patchnumber = 0;
#ifdef _WIN32
sprintf( buffer, "patches\\%s.pnach", name );
sprintf( buffer, PATCHES_DIR "\\%s.pnach", name );
#else
sprintf( buffer, "patches/%s.pnach", name );
sprintf( buffer, PATCHES_DIR "/%s.pnach", name );
#endif
f1 = fopen( buffer, "rt" );

16
pcsx2/Paths.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef PATCHES_H_INCLUDED
#define PATCHES_H_INCLUDED
#define DEFAULT_BIOS_DIR "bios"
#define DEFAULT_PLUGINS_DIR "plugins"
#define MEMCARDS_DIR "memcards"
#define PATCHES_DIR "patches"
#define SSTATES_DIR "sstates"
#define LANGS_DIR "Langs"
#define LOGS_DIR "logs"
#endif//PATCHES_H_INCLUDED

View File

@@ -26,6 +26,8 @@
#include "R3000A.h"
#include "VUmicro.h"
#include "GS.h"
#include "Paths.h"
static int inter;
@@ -404,7 +406,7 @@ void cpuBranchTest()
// if( !loaded && cpuRegs.cycle > 0x20000000 ) {
// char strstate[255];
// sprintf(strstate, "sstates/%8.8X.000", ElfCRC);
// sprintf(strstate, SSTATES_DIR "/%8.8X.000", ElfCRC);
// LoadState(strstate);
// loaded = 1;
// }

View File

@@ -23,6 +23,8 @@
#include "PsxCommon.h"
#include "Paths.h"
#ifdef _WIN32
#pragma warning(disable:4244)
#endif
@@ -575,7 +577,7 @@ FILE *LoadMcd(int mcd) {
} else {
strcpy(str, Config.Mcd2);
}
if (*str == 0) sprintf(str, "memcards/Mcd00%d.ps2", mcd);
if (*str == 0) sprintf(str, MEMCARDS_DIR "/Mcd00%d.ps2", mcd);
f = fopen(str, "r+b");
if (f == NULL) {
CreateMcd(str);

View File

@@ -23,6 +23,8 @@
#include "PsxCommon.h"
#include "Stats.h"
#include "Paths.h"
void statsOpen() {
stats.vsyncCount = 0;
stats.vsyncTime = time(NULL);
@@ -38,9 +40,9 @@ void statsClose() {
t = time(NULL) - stats.vsyncTime;
#ifdef _WIN32
f = fopen("logs\\stats.txt", "w");
f = fopen(LOGS_DIR "\\stats.txt", "w");
#else
f = fopen("logs/stats.txt", "w");
f = fopen(LOGS_DIR "/stats.txt", "w");
#endif
if (!f) { SysPrintf("Can't open stats.txt\n"); return; }
fprintf(f, "-- PCSX2 v%s statics--\n\n", PCSX2_VERSION);

View File

@@ -27,6 +27,8 @@
#include "resource.h"
#include "Win32.h"
#include "Paths.h"
HWND mcdDlg;
@@ -60,7 +62,7 @@ void Open_Mcd_Proc(HWND hW, int mcd) {
ofn.nFilterIndex = 1;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = 256;
ofn.lpstrInitialDir = "memcards";
ofn.lpstrInitialDir = MEMCARDS_DIR;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = 256;
ofn.lpstrTitle = NULL;

View File

@@ -49,6 +49,8 @@
#include "cheats/cheats.h"
#include "../Paths.h"
#define COMPILEDATE __DATE__
static int efile;
@@ -1348,16 +1350,16 @@ void ChangeLanguage(char *lang) {
static int sinit=0;
int SysInit() {
CreateDirectory("memcards", NULL);
CreateDirectory("sstates", NULL);
CreateDirectory(MEMCARDS_DIR, NULL);
CreateDirectory(SSTATES_DIR, NULL);
#ifdef EMU_LOG
CreateDirectory("logs", NULL);
CreateDirectory(LOGS_DIR, NULL);
#ifdef PCSX2_DEVBUILD
if( g_TestRun.plogname != NULL )
emuLog = fopen(g_TestRun.plogname, "w");
if( emuLog == NULL )
emuLog = fopen("logs\\emuLog.txt","w");
emuLog = fopen(LOGS_DIR "\\emuLog.txt","w");
#endif
if( emuLog != NULL )