Browse code

Updating in_2sf to use a newish version of DeSmuME, 0.9.9 from SVN. Somewhat cleaned up as well, but not everything because it's a pain in the ass.

Naram Qashat authored on 2013/04/18 17:22:55
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,426 +0,0 @@
1
-/*  Copyright 2009-2010 DeSmuME team
2
-
3
-	This file is free software: you can redistribute it and/or modify
4
-	it under the terms of the GNU General Public License as published by
5
-	the Free Software Foundation, either version 2 of the License, or
6
-	(at your option) any later version.
7
-
8
-	This file is distributed in the hope that it will be useful,
9
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
10
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
-	GNU General Public License for more details.
12
-
13
-	You should have received a copy of the GNU General Public License
14
-	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
15
-*/
16
-
17
-#include <string>
18
-
19
-#ifdef _MSC_VER
20
-#define mkdir _mkdir
21
-#endif
22
-
23
-#if defined(_WINDOWS)
24
-//#define WIN32_LEAN_AND_MEAN
25
-//#include <WinSock2.h>
26
-#include "windowsh_wrapper.h"
27
-#include <direct.h>
28
-#if !defined(WXPORT)
29
-#include "resource.h"
30
-#else
31
-#include <glib.h>
32
-#endif /* !WXPORT */
33
-#else
34
-#include <glib.h>
35
-#endif /* _WINDOWS */
36
-
37
-#include <cstdlib>
38
-#include <ctime>
39
-#include <cstdio>
40
-#include "utils/xstring.h"
41
-
42
-#ifdef _WINDOWS
43
-#define FILE_EXT_DELIMITER_CHAR		'.'
44
-#define DIRECTORY_DELIMITER_CHAR	'\\'
45
-#else
46
-#define FILE_EXT_DELIMITER_CHAR		'.'
47
-#define DIRECTORY_DELIMITER_CHAR	'/'
48
-#endif
49
-
50
-#ifdef _WINDOWS
51
-void FCEUD_MakePathDirs(const char *fname);
52
-#endif
53
-
54
-class Path
55
-{
56
-public:
57
-	static bool IsPathRooted (const std::string &path);
58
-	static std::string GetFileDirectoryPath(std::string filePath);
59
-	static std::string GetFileNameFromPath(std::string filePath);
60
-	static std::string GetFileNameWithoutExt(std::string fileName);
61
-	static std::string GetFileNameFromPathWithoutExt(std::string filePath);
62
-	static std::string GetFileExt(std::string fileName);
63
-};
64
-
65
-class PathInfo
66
-{
67
-public:
68
-
69
-	std::string path;
70
-	std::string RomName;
71
-	std::string RomDirectory;
72
-
73
-	#define MAX_FORMAT		20
74
-	#define SECTION			"PathSettings"
75
-
76
-	#define ROMKEY			"Roms"
77
-	#define BATTERYKEY		"Battery"
78
-	#define STATEKEY		"States"
79
-	#define SCREENSHOTKEY	"Screenshots"
80
-	#define AVIKEY			"AviFiles"
81
-	#define CHEATKEY		"Cheats"
82
-	#define SOUNDKEY		"SoundSamples"
83
-	#define FIRMWAREKEY		"Firmware"
84
-	#define FORMATKEY		"format"
85
-	#define DEFAULTFORMATKEY "defaultFormat"
86
-	#define NEEDSSAVINGKEY	"needsSaving"
87
-	#define LASTVISITKEY	"lastVisit"
88
-	#define LUAKEY			"Lua"
89
-	char screenshotFormat[MAX_FORMAT];
90
-	bool savelastromvisit;
91
-
92
-	enum KnownPath
93
-	{
94
-		FIRSTKNOWNPATH = 0,
95
-		ROMS = 0,
96
-		BATTERY,
97
-		STATES,
98
-		SCREENSHOTS,
99
-		AVI_FILES,
100
-		CHEATS,
101
-		SOUNDS,
102
-		FIRMWARE,
103
-		MODULE,
104
-		MAXKNOWNPATH = MODULE
105
-	};
106
-
107
-	char pathToRoms[MAX_PATH];
108
-	char pathToBattery[MAX_PATH];
109
-	char pathToStates[MAX_PATH];
110
-	char pathToScreenshots[MAX_PATH];
111
-	char pathToAviFiles[MAX_PATH];
112
-	char pathToCheats[MAX_PATH];
113
-	char pathToSounds[MAX_PATH];
114
-	char pathToFirmware[MAX_PATH];
115
-	char pathToModule[MAX_PATH];
116
-	char pathToLua[MAX_PATH];
117
-
118
-	void init(const char * filename) {
119
-
120
-		path = std::string(filename);
121
-
122
-		//extract the internal part of the logical rom name
123
-		std::vector<std::string> parts = tokenize_str(filename,"|");
124
-		SetRomName(parts[parts.size()-1].c_str());
125
-		LoadModulePath();
126
-#ifndef WIN32
127
-		//ReadPathSettings();
128
-#endif
129
-
130
-	}
131
-
132
-	void LoadModulePath()
133
-	{
134
-#if defined(_WINDOWS)
135
-
136
-		char *p;
137
-		ZeroMemory(pathToModule, sizeof(pathToModule));
138
-
139
-		GetModuleFileNameA(NULL, pathToModule, sizeof(pathToModule));
140
-		p = pathToModule + strlen(pathToModule);
141
-		while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
142
-		if (++p >= pathToModule) *p = 0;
143
-#else
144
-		char *cwd = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
145
-		g_mkdir_with_parents(cwd, 0755);
146
-		strncpy(pathToModule, cwd, MAX_PATH);
147
-		g_free(cwd);
148
-#endif
149
-	}
150
-
151
-	enum Action
152
-	{
153
-		GET,
154
-		SET
155
-	};
156
-
157
-	void GetDefaultPath(char *pathToDefault, const char *, int maxCount)
158
-	{
159
-#ifdef _WINDOWS
160
-		std::string temp = (std::string)"." + DIRECTORY_DELIMITER_CHAR + pathToDefault;
161
-		strncpy(pathToDefault, temp.c_str(), maxCount);
162
-#else
163
-		strncpy(pathToDefault, pathToModule, maxCount);
164
-#endif
165
-	}
166
-
167
-	/*void ReadKey(char *pathToRead, const char *key)
168
-	{
169
-#ifdef _WINDOWS
170
-		GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
171
-		if(strcmp(pathToRead, key) == 0) {
172
-			//since the variables are all intialized in this file they all use MAX_PATH
173
-			GetDefaultPath(pathToRead, key, MAX_PATH);
174
-		}
175
-#else
176
-		//since the variables are all intialized in this file they all use MAX_PATH
177
-		GetDefaultPath(pathToRead, key, MAX_PATH);
178
-#endif
179
-	}*/
180
-
181
-	/*void ReadPathSettings()
182
-	{
183
-		if( ( strcmp(pathToModule, "") == 0) || !pathToModule)
184
-			LoadModulePath();
185
-
186
-		ReadKey(pathToRoms, ROMKEY);
187
-		ReadKey(pathToBattery, BATTERYKEY);
188
-		ReadKey(pathToStates, STATEKEY);
189
-		ReadKey(pathToScreenshots, SCREENSHOTKEY);
190
-		ReadKey(pathToAviFiles, AVIKEY);
191
-		ReadKey(pathToCheats, CHEATKEY);
192
-		ReadKey(pathToSounds, SOUNDKEY);
193
-		ReadKey(pathToFirmware, FIRMWAREKEY);
194
-		ReadKey(pathToLua, LUAKEY);
195
-#ifdef _WINDOWS
196
-		GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
197
-		savelastromvisit	= GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName);
198
-		currentimageformat	= (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
199
-#endif*/
200
-	/*
201
-		needsSaving		= GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, true, IniName);
202
-		if(needsSaving)
203
-		{
204
-			needsSaving = false;
205
-			WritePathSettings();
206
-		}*/
207
-	/*}*/
208
-
209
-	void SwitchPath(Action action, KnownPath knownPath, char * buffer)
210
-	{
211
-		char *pathToCopy = 0;
212
-		switch(knownPath)
213
-		{
214
-		case ROMS:
215
-			pathToCopy = pathToRoms;
216
-			break;
217
-		case BATTERY:
218
-			pathToCopy = pathToBattery;
219
-			break;
220
-		case STATES:
221
-			pathToCopy = pathToStates;
222
-			break;
223
-		case SCREENSHOTS:
224
-			pathToCopy = pathToScreenshots;
225
-			break;
226
-		case AVI_FILES:
227
-			pathToCopy = pathToAviFiles;
228
-			break;
229
-		case CHEATS:
230
-			pathToCopy = pathToCheats;
231
-			break;
232
-		case SOUNDS:
233
-			pathToCopy = pathToSounds;
234
-			break;
235
-		case FIRMWARE:
236
-			pathToCopy = pathToFirmware;
237
-			break;
238
-		case MODULE:
239
-			pathToCopy = pathToModule;
240
-			break;
241
-		}
242
-
243
-		if(action == GET)
244
-		{
245
-			std::string thePath = pathToCopy;
246
-			std::string relativePath = (std::string)"." + DIRECTORY_DELIMITER_CHAR;
247
-
248
-			int len = (int)thePath.size()-1;
249
-
250
-			if(len == -1)
251
-				thePath = relativePath;
252
-			else
253
-				if(thePath[len] != DIRECTORY_DELIMITER_CHAR)
254
-					thePath += DIRECTORY_DELIMITER_CHAR;
255
-
256
-			if(!Path::IsPathRooted(thePath))
257
-			{
258
-				thePath = (std::string)pathToModule + thePath;
259
-			}
260
-
261
-			strncpy(buffer, thePath.c_str(), MAX_PATH);
262
-			#ifdef _WINDOWS
263
-			FCEUD_MakePathDirs(buffer);
264
-			#endif
265
-		}
266
-		else if(action == SET)
267
-		{
268
-			int len = strlen(buffer)-1;
269
-			if(buffer[len] == DIRECTORY_DELIMITER_CHAR)
270
-				buffer[len] = '\0';
271
-
272
-			strncpy(pathToCopy, buffer, MAX_PATH);
273
-		}
274
-	}
275
-
276
-	std::string getpath(KnownPath knownPath)
277
-	{
278
-		char temp[MAX_PATH];
279
-		SwitchPath(GET, knownPath, temp);
280
-		return temp;
281
-	}
282
-
283
-	void getpath(KnownPath knownPath, char *buffer)
284
-	{
285
-		SwitchPath(GET, knownPath, buffer);
286
-	}
287
-
288
-	void setpath(KnownPath knownPath, char *buffer)
289
-	{
290
-		SwitchPath(SET, knownPath, buffer);
291
-	}
292
-
293
-	void getfilename(char *buffer, int)
294
-	{
295
-		strcpy(buffer,noextension().c_str());
296
-	}
297
-
298
-	void getpathnoext(KnownPath knownPath, char *buffer)
299
-	{
300
-		getpath(knownPath, buffer);
301
-		strcat(buffer, GetRomNameWithoutExtension().c_str());
302
-	}
303
-
304
-	std::string extension()
305
-	{
306
-		return Path::GetFileExt(path);
307
-	}
308
-
309
-	std::string noextension()
310
-	{
311
-		std::string romNameWithPath = Path::GetFileDirectoryPath(path) + DIRECTORY_DELIMITER_CHAR + Path::GetFileNameWithoutExt(RomName);
312
-
313
-		return romNameWithPath;
314
-	}
315
-
316
-	void formatname(char *output)
317
-	{
318
-		std::string file;
319
-		time_t now = time(NULL);
320
-		tm *time_struct = localtime(&now);
321
-		srand((unsigned int)now);
322
-
323
-		for(int i = 0; i < MAX_FORMAT;i++)
324
-		{
325
-			char *c = &screenshotFormat[i];
326
-			char tmp[MAX_PATH] = {0};
327
-
328
-			if(*c == '%')
329
-			{
330
-				c = &screenshotFormat[++i];
331
-				switch(*c)
332
-				{
333
-				case 'f':
334
-
335
-					strcat(tmp, GetRomNameWithoutExtension().c_str());
336
-					break;
337
-				case 'D':
338
-					strftime(tmp, MAX_PATH, "%d", time_struct);
339
-					break;
340
-				case 'M':
341
-					strftime(tmp, MAX_PATH, "%m", time_struct);
342
-					break;
343
-				case 'Y':
344
-					strftime(tmp, MAX_PATH, "%Y", time_struct);
345
-					break;
346
-				case 'h':
347
-					strftime(tmp, MAX_PATH, "%H", time_struct);
348
-					break;
349
-				case 'm':
350
-					strftime(tmp, MAX_PATH, "%M", time_struct);
351
-					break;
352
-				case 's':
353
-					strftime(tmp, MAX_PATH, "%S", time_struct);
354
-					break;
355
-				case 'r':
356
-					sprintf(tmp, "%d", rand() % RAND_MAX);
357
-					break;
358
-				}
359
-			}
360
-			else
361
-			{
362
-				int j;
363
-				for(j=i;j<MAX_FORMAT-i;j++)
364
-					if(screenshotFormat[j] != '%')
365
-						tmp[j-i]=screenshotFormat[j];
366
-					else
367
-						break;
368
-				tmp[j-i]='\0';
369
-			}
370
-			file += tmp;
371
-		}
372
-		strncpy(output, file.c_str(), MAX_PATH);
373
-	}
374
-
375
-	enum ImageFormat
376
-	{
377
-#if defined(_WINDOWS) && !defined(WXPORT)
378
-		PNG = IDC_PNG,
379
-		BMP = IDC_BMP
380
-#else
381
-		PNG,
382
-		BMP
383
-#endif
384
-	};
385
-
386
-	ImageFormat currentimageformat;
387
-
388
-	ImageFormat imageformat() {
389
-		return currentimageformat;
390
-	}
391
-
392
-	void SetRomName(const char *filename)
393
-	{
394
-		std::string romPath = filename;
395
-
396
-		RomName = Path::GetFileNameFromPath(romPath);
397
-		RomDirectory = Path::GetFileDirectoryPath(romPath);
398
-	}
399
-
400
-	const char *GetRomName()
401
-	{
402
-		return RomName.c_str();
403
-	}
404
-
405
-	std::string GetRomNameWithoutExtension()
406
-	{
407
-		return Path::GetFileNameWithoutExt(RomName);
408
-	}
409
-
410
-	bool isdsgba(std::string fileName)
411
-	{
412
-		size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
413
-
414
-		if (i != std::string::npos) {
415
-			fileName = fileName.substr(i - 2);
416
-		}
417
-
418
-		if(fileName == "ds.gba") {
419
-			return true;
420
-		}
421
-
422
-		return false;
423
-	}
424
-};
425
-
426
-extern PathInfo path;
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,426 @@
1
+/*  Copyright 2009-2010 DeSmuME team
2
+
3
+	This file is free software: you can redistribute it and/or modify
4
+	it under the terms of the GNU General Public License as published by
5
+	the Free Software Foundation, either version 2 of the License, or
6
+	(at your option) any later version.
7
+
8
+	This file is distributed in the hope that it will be useful,
9
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
+	GNU General Public License for more details.
12
+
13
+	You should have received a copy of the GNU General Public License
14
+	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
15
+*/
16
+
17
+#include <string>
18
+
19
+#ifdef _MSC_VER
20
+#define mkdir _mkdir
21
+#endif
22
+
23
+#if defined(_WINDOWS)
24
+//#define WIN32_LEAN_AND_MEAN
25
+//#include <WinSock2.h>
26
+#include "windowsh_wrapper.h"
27
+#include <direct.h>
28
+#if !defined(WXPORT)
29
+#include "resource.h"
30
+#else
31
+#include <glib.h>
32
+#endif /* !WXPORT */
33
+#else
34
+#include <glib.h>
35
+#endif /* _WINDOWS */
36
+
37
+#include <cstdlib>
38
+#include <ctime>
39
+#include <cstdio>
40
+#include "utils/xstring.h"
41
+
42
+#ifdef _WINDOWS
43
+#define FILE_EXT_DELIMITER_CHAR		'.'
44
+#define DIRECTORY_DELIMITER_CHAR	'\\'
45
+#else
46
+#define FILE_EXT_DELIMITER_CHAR		'.'
47
+#define DIRECTORY_DELIMITER_CHAR	'/'
48
+#endif
49
+
50
+#ifdef _WINDOWS
51
+void FCEUD_MakePathDirs(const char *fname);
52
+#endif
53
+
54
+class Path
55
+{
56
+public:
57
+	static bool IsPathRooted (const std::string &path);
58
+	static std::string GetFileDirectoryPath(std::string filePath);
59
+	static std::string GetFileNameFromPath(std::string filePath);
60
+	static std::string GetFileNameWithoutExt(std::string fileName);
61
+	static std::string GetFileNameFromPathWithoutExt(std::string filePath);
62
+	static std::string GetFileExt(std::string fileName);
63
+};
64
+
65
+class PathInfo
66
+{
67
+public:
68
+
69
+	std::string path;
70
+	std::string RomName;
71
+	std::string RomDirectory;
72
+
73
+	#define MAX_FORMAT		20
74
+	#define SECTION			"PathSettings"
75
+
76
+	#define ROMKEY			"Roms"
77
+	#define BATTERYKEY		"Battery"
78
+	#define STATEKEY		"States"
79
+	#define SCREENSHOTKEY	"Screenshots"
80
+	#define AVIKEY			"AviFiles"
81
+	#define CHEATKEY		"Cheats"
82
+	#define SOUNDKEY		"SoundSamples"
83
+	#define FIRMWAREKEY		"Firmware"
84
+	#define FORMATKEY		"format"
85
+	#define DEFAULTFORMATKEY "defaultFormat"
86
+	#define NEEDSSAVINGKEY	"needsSaving"
87
+	#define LASTVISITKEY	"lastVisit"
88
+	#define LUAKEY			"Lua"
89
+	char screenshotFormat[MAX_FORMAT];
90
+	bool savelastromvisit;
91
+
92
+	enum KnownPath
93
+	{
94
+		FIRSTKNOWNPATH = 0,
95
+		ROMS = 0,
96
+		BATTERY,
97
+		STATES,
98
+		SCREENSHOTS,
99
+		AVI_FILES,
100
+		CHEATS,
101
+		SOUNDS,
102
+		FIRMWARE,
103
+		MODULE,
104
+		MAXKNOWNPATH = MODULE
105
+	};
106
+
107
+	char pathToRoms[MAX_PATH];
108
+	char pathToBattery[MAX_PATH];
109
+	char pathToStates[MAX_PATH];
110
+	char pathToScreenshots[MAX_PATH];
111
+	char pathToAviFiles[MAX_PATH];
112
+	char pathToCheats[MAX_PATH];
113
+	char pathToSounds[MAX_PATH];
114
+	char pathToFirmware[MAX_PATH];
115
+	char pathToModule[MAX_PATH];
116
+	char pathToLua[MAX_PATH];
117
+
118
+	void init(const char * filename) {
119
+
120
+		path = std::string(filename);
121
+
122
+		//extract the internal part of the logical rom name
123
+		std::vector<std::string> parts = tokenize_str(filename,"|");
124
+		SetRomName(parts[parts.size()-1].c_str());
125
+		LoadModulePath();
126
+#ifndef WIN32
127
+		//ReadPathSettings();
128
+#endif
129
+
130
+	}
131
+
132
+	void LoadModulePath()
133
+	{
134
+#if defined(_WINDOWS)
135
+
136
+		char *p;
137
+		ZeroMemory(pathToModule, sizeof(pathToModule));
138
+
139
+		GetModuleFileNameA(NULL, pathToModule, sizeof(pathToModule));
140
+		p = pathToModule + strlen(pathToModule);
141
+		while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
142
+		if (++p >= pathToModule) *p = 0;
143
+#else
144
+		char *cwd = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
145
+		g_mkdir_with_parents(cwd, 0755);
146
+		strncpy(pathToModule, cwd, MAX_PATH);
147
+		g_free(cwd);
148
+#endif
149
+	}
150
+
151
+	enum Action
152
+	{
153
+		GET,
154
+		SET
155
+	};
156
+
157
+	void GetDefaultPath(char *pathToDefault, const char *, int maxCount)
158
+	{
159
+#ifdef _WINDOWS
160
+		std::string temp = (std::string)"." + DIRECTORY_DELIMITER_CHAR + pathToDefault;
161
+		strncpy(pathToDefault, temp.c_str(), maxCount);
162
+#else
163
+		strncpy(pathToDefault, pathToModule, maxCount);
164
+#endif
165
+	}
166
+
167
+	/*void ReadKey(char *pathToRead, const char *key)
168
+	{
169
+#ifdef _WINDOWS
170
+		GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
171
+		if(strcmp(pathToRead, key) == 0) {
172
+			//since the variables are all intialized in this file they all use MAX_PATH
173
+			GetDefaultPath(pathToRead, key, MAX_PATH);
174
+		}
175
+#else
176
+		//since the variables are all intialized in this file they all use MAX_PATH
177
+		GetDefaultPath(pathToRead, key, MAX_PATH);
178
+#endif
179
+	}*/
180
+
181
+	/*void ReadPathSettings()
182
+	{
183
+		if( ( strcmp(pathToModule, "") == 0) || !pathToModule)
184
+			LoadModulePath();
185
+
186
+		ReadKey(pathToRoms, ROMKEY);
187
+		ReadKey(pathToBattery, BATTERYKEY);
188
+		ReadKey(pathToStates, STATEKEY);
189
+		ReadKey(pathToScreenshots, SCREENSHOTKEY);
190
+		ReadKey(pathToAviFiles, AVIKEY);
191
+		ReadKey(pathToCheats, CHEATKEY);
192
+		ReadKey(pathToSounds, SOUNDKEY);
193
+		ReadKey(pathToFirmware, FIRMWAREKEY);
194
+		ReadKey(pathToLua, LUAKEY);
195
+#ifdef _WINDOWS
196
+		GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
197
+		savelastromvisit	= GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName);
198
+		currentimageformat	= (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
199
+#endif*/
200
+	/*
201
+		needsSaving		= GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, true, IniName);
202
+		if(needsSaving)
203
+		{
204
+			needsSaving = false;
205
+			WritePathSettings();
206
+		}*/
207
+	/*}*/
208
+
209
+	void SwitchPath(Action action, KnownPath knownPath, char * buffer)
210
+	{
211
+		char *pathToCopy = 0;
212
+		switch(knownPath)
213
+		{
214
+		case ROMS:
215
+			pathToCopy = pathToRoms;
216
+			break;
217
+		case BATTERY:
218
+			pathToCopy = pathToBattery;
219
+			break;
220
+		case STATES:
221
+			pathToCopy = pathToStates;
222
+			break;
223
+		case SCREENSHOTS:
224
+			pathToCopy = pathToScreenshots;
225
+			break;
226
+		case AVI_FILES:
227
+			pathToCopy = pathToAviFiles;
228
+			break;
229
+		case CHEATS:
230
+			pathToCopy = pathToCheats;
231
+			break;
232
+		case SOUNDS:
233
+			pathToCopy = pathToSounds;
234
+			break;
235
+		case FIRMWARE:
236
+			pathToCopy = pathToFirmware;
237
+			break;
238
+		case MODULE:
239
+			pathToCopy = pathToModule;
240
+			break;
241
+		}
242
+
243
+		if(action == GET)
244
+		{
245
+			std::string thePath = pathToCopy;
246
+			std::string relativePath = (std::string)"." + DIRECTORY_DELIMITER_CHAR;
247
+
248
+			int len = (int)thePath.size()-1;
249
+
250
+			if(len == -1)
251
+				thePath = relativePath;
252
+			else
253
+				if(thePath[len] != DIRECTORY_DELIMITER_CHAR)
254
+					thePath += DIRECTORY_DELIMITER_CHAR;
255
+
256
+			if(!Path::IsPathRooted(thePath))
257
+			{
258
+				thePath = (std::string)pathToModule + thePath;
259
+			}
260
+
261
+			strncpy(buffer, thePath.c_str(), MAX_PATH);
262
+			#ifdef _WINDOWS
263
+			FCEUD_MakePathDirs(buffer);
264
+			#endif
265
+		}
266
+		else if(action == SET)
267
+		{
268
+			int len = strlen(buffer)-1;
269
+			if(buffer[len] == DIRECTORY_DELIMITER_CHAR)
270
+				buffer[len] = '\0';
271
+
272
+			strncpy(pathToCopy, buffer, MAX_PATH);
273
+		}
274
+	}
275
+
276
+	std::string getpath(KnownPath knownPath)
277
+	{
278
+		char temp[MAX_PATH];
279
+		SwitchPath(GET, knownPath, temp);
280
+		return temp;
281
+	}
282
+
283
+	void getpath(KnownPath knownPath, char *buffer)
284
+	{
285
+		SwitchPath(GET, knownPath, buffer);
286
+	}
287
+
288
+	void setpath(KnownPath knownPath, char *buffer)
289
+	{
290
+		SwitchPath(SET, knownPath, buffer);
291
+	}
292
+
293
+	void getfilename(char *buffer, int)
294
+	{
295
+		strcpy(buffer,noextension().c_str());
296
+	}
297
+
298
+	void getpathnoext(KnownPath knownPath, char *buffer)
299
+	{
300
+		getpath(knownPath, buffer);
301
+		strcat(buffer, GetRomNameWithoutExtension().c_str());
302
+	}
303
+
304
+	std::string extension()
305
+	{
306
+		return Path::GetFileExt(path);
307
+	}
308
+
309
+	std::string noextension()
310
+	{
311
+		std::string romNameWithPath = Path::GetFileDirectoryPath(path) + DIRECTORY_DELIMITER_CHAR + Path::GetFileNameWithoutExt(RomName);
312
+
313
+		return romNameWithPath;
314
+	}
315
+
316
+	void formatname(char *output)
317
+	{
318
+		std::string file;
319
+		time_t now = time(NULL);
320
+		tm *time_struct = localtime(&now);
321
+		srand((unsigned int)now);
322
+
323
+		for(int i = 0; i < MAX_FORMAT;i++)
324
+		{
325
+			char *c = &screenshotFormat[i];
326
+			char tmp[MAX_PATH] = {0};
327
+
328
+			if(*c == '%')
329
+			{
330
+				c = &screenshotFormat[++i];
331
+				switch(*c)
332
+				{
333
+				case 'f':
334
+
335
+					strcat(tmp, GetRomNameWithoutExtension().c_str());
336
+					break;
337
+				case 'D':
338
+					strftime(tmp, MAX_PATH, "%d", time_struct);
339
+					break;
340
+				case 'M':
341
+					strftime(tmp, MAX_PATH, "%m", time_struct);
342
+					break;
343
+				case 'Y':
344
+					strftime(tmp, MAX_PATH, "%Y", time_struct);
345
+					break;
346
+				case 'h':
347
+					strftime(tmp, MAX_PATH, "%H", time_struct);
348
+					break;
349
+				case 'm':
350
+					strftime(tmp, MAX_PATH, "%M", time_struct);
351
+					break;
352
+				case 's':
353
+					strftime(tmp, MAX_PATH, "%S", time_struct);
354
+					break;
355
+				case 'r':
356
+					sprintf(tmp, "%d", rand() % RAND_MAX);
357
+					break;
358
+				}
359
+			}
360
+			else
361
+			{
362
+				int j;
363
+				for(j=i;j<MAX_FORMAT-i;j++)
364
+					if(screenshotFormat[j] != '%')
365
+						tmp[j-i]=screenshotFormat[j];
366
+					else
367
+						break;
368
+				tmp[j-i]='\0';
369
+			}
370
+			file += tmp;
371
+		}
372
+		strncpy(output, file.c_str(), MAX_PATH);
373
+	}
374
+
375
+	enum ImageFormat
376
+	{
377
+#if defined(_WINDOWS) && !defined(WXPORT)
378
+		PNG = IDC_PNG,
379
+		BMP = IDC_BMP
380
+#else
381
+		PNG,
382
+		BMP
383
+#endif
384
+	};
385
+
386
+	ImageFormat currentimageformat;
387
+
388
+	ImageFormat imageformat() {
389
+		return currentimageformat;
390
+	}
391
+
392
+	void SetRomName(const char *filename)
393
+	{
394
+		std::string romPath = filename;
395
+
396
+		RomName = Path::GetFileNameFromPath(romPath);
397
+		RomDirectory = Path::GetFileDirectoryPath(romPath);
398
+	}
399
+
400
+	const char *GetRomName()
401
+	{
402
+		return RomName.c_str();
403
+	}
404
+
405
+	std::string GetRomNameWithoutExtension()
406
+	{
407
+		return Path::GetFileNameWithoutExt(RomName);
408
+	}
409
+
410
+	bool isdsgba(std::string fileName)
411
+	{
412
+		size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
413
+
414
+		if (i != std::string::npos) {
415
+			fileName = fileName.substr(i - 2);
416
+		}
417
+
418
+		if(fileName == "ds.gba") {
419
+			return true;
420
+		}
421
+
422
+		return false;
423
+	}
424
+};
425
+
426
+extern PathInfo path;