Skip to content

Commit 1d4c110

Browse files
committed
ModAPI.Common: use Path.Combine() in SporePath.cs
1 parent 9346334 commit 1d4c110

File tree

1 file changed

+11
-45
lines changed

1 file changed

+11
-45
lines changed

ModAPI.Common/SporePath.cs

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,15 @@ public static string GetRealParent(string path)
149149
// This method returns the path to the folder that contains the executable
150150
public static string MoveToSporebinEP1(string path, bool recursive = true)
151151
{
152-
if (!path.EndsWith("\\"))
153-
{
154-
path += "\\";
155-
}
156-
157-
if (File.Exists(path + "SporeApp.exe"))
152+
if (File.Exists(Path.Combine(path, "SporeApp.exe")))
158153
{
159154
return path;
160155
}
161156

162-
if (Directory.Exists(path + "SporebinEP1"))
157+
string sporeBinEP1Path = Path.Combine(path, "SporebinEP1");
158+
if (Directory.Exists(sporeBinEP1Path))
163159
{
164-
return path + "SporebinEP1\\";
160+
return sporeBinEP1Path;
165161
}
166162

167163
if (recursive)
@@ -176,19 +172,15 @@ public static string MoveToSporebinEP1(string path, bool recursive = true)
176172
// This method returns the path to the folder that contains the executable
177173
public static string MoveToSporebin(string path, bool recursive = true)
178174
{
179-
if (!path.EndsWith("\\"))
180-
{
181-
path += "\\";
182-
}
183-
184-
if (File.Exists(path + "SporeApp.exe"))
175+
if (File.Exists(Path.Combine(path, "SporeApp.exe")))
185176
{
186177
return path;
187178
}
188179

189-
if (Directory.Exists(path + "Sporebin"))
180+
string sporeBinPath = Path.Combine(path, "Sporebin");
181+
if (Directory.Exists(sporeBinPath))
190182
{
191-
return path + "Sporebin\\";
183+
return sporeBinPath;
192184
}
193185

194186
if (recursive)
@@ -200,49 +192,23 @@ public static string MoveToSporebin(string path, bool recursive = true)
200192
return null;
201193
}
202194

203-
public static string MoveToSteam(string path, bool recursive = true)
204-
{
205-
if (!path.EndsWith("\\"))
206-
{
207-
path += "\\";
208-
}
209-
210-
if (File.Exists(path + "Steam.exe"))
211-
{
212-
return path;
213-
}
214-
215-
if (Directory.Exists(path + "Steam"))
216-
{
217-
return path + "Steam\\";
218-
}
219-
220-
if (recursive)
221-
{
222-
// check if the user selected another folder (for example, "steamapps")
223-
return MoveToSteam(GetRealParent(path), false);
224-
}
225-
226-
return null;
227-
}
228-
229195
public static string MoveToData(Game game, string installationDirectory)
230196
{
231197
if (game == Game.Spore)
232198
{
233-
return Path.Combine(new string[] {installationDirectory, "Data"});
199+
return Path.Combine(installationDirectory, "Data");
234200
}
235201
else if (game == Game.GalacticAdventures)
236202
{
237203
// Steam and GoG uses DataEP1
238-
string outputPath = Path.Combine(new string[] { installationDirectory, "DataEP1" });
204+
string outputPath = Path.Combine(installationDirectory, "DataEP1");
239205
if (Directory.Exists(outputPath))
240206
{
241207
return outputPath;
242208
}
243209
else
244210
{
245-
return Path.Combine(new string[] { installationDirectory, "Data" });
211+
return Path.Combine(installationDirectory, "Data");
246212
}
247213
}
248214
else

0 commit comments

Comments
 (0)