Skip to content

Commit b670fcd

Browse files
committed
Improved path resolving, 64bit too...
1 parent c83be42 commit b670fcd

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

External/Plugins/SourceControl/PluginMain.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,14 @@ public void LoadSettings()
333333
// Try to find git path from program files
334334
if (settingObject.GITPath == "git.exe")
335335
{
336-
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
337-
String gitPath = Path.Combine(programFiles, @"Git\bin\git.exe");
336+
String gitPath = PathHelper.FindFromProgramFiles(@"Git\bin\git.exe");
338337
if (File.Exists(gitPath)) settingObject.GITPath = gitPath;
339338

340339
}
341340
// Try to find TortoiseProc path from program files
342341
if (settingObject.TortoiseGITProcPath == "TortoiseGitProc.exe")
343342
{
344-
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
345-
String torProcPath = Path.Combine(programFiles, @"TortoiseGit\bin\TortoiseGitProc.exe");
343+
String torProcPath = PathHelper.FindFromProgramFiles(@"TortoiseGit\bin\TortoiseGitProc.exe");
346344
if (File.Exists(torProcPath)) settingObject.TortoiseGITProcPath = torProcPath;
347345
}
348346

@@ -359,22 +357,19 @@ public void LoadSettings()
359357
// Try to find sliksvn path from program files
360358
if (settingObject.SVNPath == "svn.exe")
361359
{
362-
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
363-
String slSvnPath = Path.Combine(programFiles, @"SlikSvn\bin\svn.exe");
360+
String slSvnPath = PathHelper.FindFromProgramFiles(@"SlikSvn\bin\svn.exe");
364361
if (File.Exists(slSvnPath)) settingObject.SVNPath = slSvnPath;
365362
}
366363
// Try to find svn from TortoiseSVN
367364
if (settingObject.SVNPath == "svn.exe")
368365
{
369-
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
370-
String torSvnPath = Path.Combine(programFiles, @"TortoiseSVN\bin\svn.exe");
366+
String torSvnPath = PathHelper.FindFromProgramFiles(@"TortoiseSVN\bin\svn.exe");
371367
if (File.Exists(torSvnPath)) settingObject.SVNPath = torSvnPath;
372368
}
373369
// Try to find TortoiseProc path from program files
374370
if (settingObject.TortoiseSVNProcPath == "TortoiseProc.exe")
375371
{
376-
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
377-
String torProcPath = Path.Combine(programFiles, @"TortoiseSVN\bin\TortoiseProc.exe");
372+
String torProcPath = PathHelper.FindFromProgramFiles(@"TortoiseSVN\bin\TortoiseProc.exe");
378373
if (File.Exists(torProcPath)) settingObject.TortoiseSVNProcPath = torProcPath;
379374
}
380375

PluginCore/PluginCore/Helpers/PathHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,23 @@ public static String GetPhysicalPathName(String path)
377377
}
378378
}
379379

380+
/// <summary>
381+
/// Finds an app from 32-bit or 64-bit program files directories
382+
/// </summary>
383+
public static String FindFromProgramFiles(String partialPath)
384+
{
385+
// This return always x86, FlashDevelop is x86
386+
String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
387+
String toolPath = Path.Combine(programFiles, partialPath);
388+
if (File.Exists(toolPath)) return toolPath;
389+
if (toolPath.Contains(" Files (x86)")) // Is the app in x64 program files?
390+
{
391+
toolPath = Path.Combine(programFiles.Replace(" Files (x86)", " Files"), partialPath);
392+
if (File.Exists(toolPath)) return toolPath;
393+
}
394+
return String.Empty;
395+
}
396+
380397
/// <summary>
381398
/// Gets the 32-bit Java install path
382399
/// </summary>

0 commit comments

Comments
 (0)