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,157 +0,0 @@
1
-/*
2
-	Copyright (C) 2009-2011 DeSmuME team
3
-
4
-	This file is free software: you can redistribute it and/or modify
5
-	it under the terms of the GNU General Public License as published by
6
-	the Free Software Foundation, either version 2 of the License, or
7
-	(at your option) any later version.
8
-
9
-	This file is distributed in the hope that it will be useful,
10
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-	GNU General Public License for more details.
13
-
14
-	You should have received a copy of the GNU General Public License
15
-	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
16
-*/
17
-
18
-#include "types.h"
19
-
20
-#include "path.h"
21
-#include <cstdio>
22
-
23
-//-----------------------------------
24
-//This is taken from mono Path.cs
25
-static const char InvalidPathChars[] = {
26
-	'\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
27
-	'\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F', '\x10', '\x11', '\x12',
28
-	'\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D',
29
-	'\x1E', '\x1F'
30
-};
31
-
32
-//but it is sort of windows-specific. Does it work in linux? Maybe we'll have to make it smarter
33
-static const char VolumeSeparatorChar = ':';
34
-static const char AltDirectorySeparatorChar = '/';
35
-static bool dirEqualsVolume = (DIRECTORY_DELIMITER_CHAR == VolumeSeparatorChar);
36
-
37
-
38
-bool Path::IsPathRooted (const std::string &pth)
39
-{
40
-	if (pth.empty()) {
41
-		return false;
42
-	}
43
-
44
-	if (pth.find_first_of(InvalidPathChars) != std::string::npos) {
45
-		return false;
46
-	}
47
-
48
-	char c = pth[0];
49
-	return c == DIRECTORY_DELIMITER_CHAR 	||
50
-			c == AltDirectorySeparatorChar 	||
51
-			(!dirEqualsVolume && pth.size() > 1 && pth[1] == VolumeSeparatorChar);
52
-}
53
-
54
-std::string Path::GetFileDirectoryPath(std::string filePath)
55
-{
56
-	if (filePath.empty()) {
57
-		return "";
58
-	}
59
-
60
-	size_t i = filePath.find_last_of(DIRECTORY_DELIMITER_CHAR);
61
-	if (i == std::string::npos) {
62
-		return filePath;
63
-	}
64
-
65
-	return filePath.substr(0, i);
66
-}
67
-
68
-std::string Path::GetFileNameFromPath(std::string filePath)
69
-{
70
-	if (filePath.empty()) {
71
-		return "";
72
-	}
73
-
74
-	size_t i = filePath.find_last_of(DIRECTORY_DELIMITER_CHAR);
75
-	if (i == std::string::npos) {
76
-		return filePath;
77
-	}
78
-
79
-	return filePath.substr(i + 1);
80
-}
81
-
82
-std::string Path::GetFileNameWithoutExt(std::string fileName)
83
-{
84
-	if (fileName.empty()) {
85
-		return "";
86
-	}
87
-
88
-	size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
89
-	if (i == std::string::npos) {
90
-		return fileName;
91
-	}
92
-
93
-	return fileName.substr(0, i);
94
-}
95
-
96
-std::string Path::GetFileNameFromPathWithoutExt(std::string filePath)
97
-{
98
-	if (filePath.empty()) {
99
-		return "";
100
-	}
101
-
102
-	std::string fileName = GetFileNameFromPath(filePath);
103
-
104
-	return GetFileNameWithoutExt(fileName);
105
-}
106
-
107
-std::string Path::GetFileExt(std::string fileName)
108
-{
109
-	if (fileName.empty()) {
110
-		return "";
111
-	}
112
-
113
-	size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
114
-	if (i == std::string::npos) {
115
-		return fileName;
116
-	}
117
-
118
-	return fileName.substr(i + 1);
119
-}
120
-
121
-//-----------------------------------
122
-#ifdef _WINDOWS
123
-void FCEUD_MakePathDirs(const char *fname)
124
-{
125
-	char Path[MAX_PATH];
126
-	const char* div = fname;
127
-
128
-	do
129
-	{
130
-		const char* fptr = strchr(div, '\\');
131
-
132
-		if(!fptr)
133
-		{
134
-			fptr = strchr(div, '/');
135
-		}
136
-
137
-		if(!fptr)
138
-		{
139
-			break;
140
-		}
141
-
142
-		int off = fptr - fname;
143
-		strncpy(Path, fname, off);
144
-		Path[off] = '\0';
145
-		mkdir(Path);
146
-
147
-		div = fptr + 1;
148
-
149
-		while(div[0] == '\\' || div[0] == '/')
150
-		{
151
-			div++;
152
-		}
153
-
154
-	} while(1);
155
-}
156
-#endif
157
-//------------------------------
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,157 @@
1
+/*
2
+	Copyright (C) 2009-2011 DeSmuME team
3
+
4
+	This file is free software: you can redistribute it and/or modify
5
+	it under the terms of the GNU General Public License as published by
6
+	the Free Software Foundation, either version 2 of the License, or
7
+	(at your option) any later version.
8
+
9
+	This file is distributed in the hope that it will be useful,
10
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+	GNU General Public License for more details.
13
+
14
+	You should have received a copy of the GNU General Public License
15
+	along with the this software.  If not, see <http://www.gnu.org/licenses/>.
16
+*/
17
+
18
+#include "types.h"
19
+
20
+#include "path.h"
21
+#include <cstdio>
22
+
23
+//-----------------------------------
24
+//This is taken from mono Path.cs
25
+static const char InvalidPathChars[] = {
26
+	'\x22', '\x3C', '\x3E', '\x7C', '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
27
+	'\x08', '\x09', '\x0A', '\x0B', '\x0C', '\x0D', '\x0E', '\x0F', '\x10', '\x11', '\x12',
28
+	'\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1A', '\x1B', '\x1C', '\x1D',
29
+	'\x1E', '\x1F'
30
+};
31
+
32
+//but it is sort of windows-specific. Does it work in linux? Maybe we'll have to make it smarter
33
+static const char VolumeSeparatorChar = ':';
34
+static const char AltDirectorySeparatorChar = '/';
35
+static bool dirEqualsVolume = (DIRECTORY_DELIMITER_CHAR == VolumeSeparatorChar);
36
+
37
+
38
+bool Path::IsPathRooted (const std::string &pth)
39
+{
40
+	if (pth.empty()) {
41
+		return false;
42
+	}
43
+
44
+	if (pth.find_first_of(InvalidPathChars) != std::string::npos) {
45
+		return false;
46
+	}
47
+
48
+	char c = pth[0];
49
+	return c == DIRECTORY_DELIMITER_CHAR 	||
50
+			c == AltDirectorySeparatorChar 	||
51
+			(!dirEqualsVolume && pth.size() > 1 && pth[1] == VolumeSeparatorChar);
52
+}
53
+
54
+std::string Path::GetFileDirectoryPath(std::string filePath)
55
+{
56
+	if (filePath.empty()) {
57
+		return "";
58
+	}
59
+
60
+	size_t i = filePath.find_last_of(DIRECTORY_DELIMITER_CHAR);
61
+	if (i == std::string::npos) {
62
+		return filePath;
63
+	}
64
+
65
+	return filePath.substr(0, i);
66
+}
67
+
68
+std::string Path::GetFileNameFromPath(std::string filePath)
69
+{
70
+	if (filePath.empty()) {
71
+		return "";
72
+	}
73
+
74
+	size_t i = filePath.find_last_of(DIRECTORY_DELIMITER_CHAR);
75
+	if (i == std::string::npos) {
76
+		return filePath;
77
+	}
78
+
79
+	return filePath.substr(i + 1);
80
+}
81
+
82
+std::string Path::GetFileNameWithoutExt(std::string fileName)
83
+{
84
+	if (fileName.empty()) {
85
+		return "";
86
+	}
87
+
88
+	size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
89
+	if (i == std::string::npos) {
90
+		return fileName;
91
+	}
92
+
93
+	return fileName.substr(0, i);
94
+}
95
+
96
+std::string Path::GetFileNameFromPathWithoutExt(std::string filePath)
97
+{
98
+	if (filePath.empty()) {
99
+		return "";
100
+	}
101
+
102
+	std::string fileName = GetFileNameFromPath(filePath);
103
+
104
+	return GetFileNameWithoutExt(fileName);
105
+}
106
+
107
+std::string Path::GetFileExt(std::string fileName)
108
+{
109
+	if (fileName.empty()) {
110
+		return "";
111
+	}
112
+
113
+	size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
114
+	if (i == std::string::npos) {
115
+		return fileName;
116
+	}
117
+
118
+	return fileName.substr(i + 1);
119
+}
120
+
121
+//-----------------------------------
122
+#ifdef _WINDOWS
123
+void FCEUD_MakePathDirs(const char *fname)
124
+{
125
+	char Path[MAX_PATH];
126
+	const char* div = fname;
127
+
128
+	do
129
+	{
130
+		const char* fptr = strchr(div, '\\');
131
+
132
+		if(!fptr)
133
+		{
134
+			fptr = strchr(div, '/');
135
+		}
136
+
137
+		if(!fptr)
138
+		{
139
+			break;
140
+		}
141
+
142
+		int off = fptr - fname;
143
+		strncpy(Path, fname, off);
144
+		Path[off] = '\0';
145
+		mkdir(Path);
146
+
147
+		div = fptr + 1;
148
+
149
+		while(div[0] == '\\' || div[0] == '/')
150
+		{
151
+			div++;
152
+		}
153
+
154
+	} while(1);
155
+}
156
+#endif
157
+//------------------------------