File size: 3,736 Bytes
18a519f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | using System;
using System.Collections.Generic;
using System.IO;
using Codice.Utils;
namespace Unity.PlasticSCM.Editor.Tool
{
internal static class IsExeAvailable
{
internal static bool ForMode(bool isGluonMode)
{
string toolPath = isGluonMode ?
PlasticInstallPath.GetGluonExePath() :
PlasticInstallPath.GetPlasticExePath();
return !string.IsNullOrEmpty(toolPath);
}
}
internal static class PlasticInstallPath
{
internal static string GetClientBinDir()
{
if (PlatformIdentifier.IsWindows())
{
string plasticExePath = GetPlasticExePath();
if (plasticExePath == null)
return null;
return Path.GetDirectoryName(plasticExePath);
}
if (PlatformIdentifier.IsMac())
{
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
if (path != null)
return GetExistingDir(ToolConstants.NEW_MACOS_BINDIR);
return GetExistingDir(ToolConstants.LEGACY_MACOS_BINDIR);
}
return null;
}
internal static string GetPlasticExePath()
{
if (PlatformIdentifier.IsWindows())
return FindTool.ObtainToolCommand(
Plastic.GUI_WINDOWS,
new List<String>() { GetWindowsInstallationFolder() });
if (PlatformIdentifier.IsMac())
{
string path = GetToolCommand(Plastic.NEW_GUI_MACOS);
if(path != null)
return path;
return GetToolCommand(Plastic.LEGACY_GUI_MACOS);
}
return null;
}
internal static string GetGluonExePath()
{
if (PlatformIdentifier.IsWindows())
return FindTool.ObtainToolCommand(
Gluon.GUI_WINDOWS,
new List<String>() { GetWindowsInstallationFolder() });
if (PlatformIdentifier.IsMac())
{
string path = GetToolCommand(Gluon.NEW_GUI_MACOS);
if (path != null)
return path;
return GetToolCommand(Gluon.LEGACY_GUI_MACOS);
}
return null;
}
static string GetToolCommand(string tool)
{
return File.Exists(tool) ? tool : null;
}
static string GetExistingDir(string directory)
{
return Directory.Exists(directory) ? directory : null;
}
static string GetWindowsInstallationFolder()
{
string programFilesFolder = Environment.GetFolderPath(
Environment.SpecialFolder.ProgramFiles);
return Path.Combine(Path.Combine(programFilesFolder,
PLASTICSCM_FOLDER), PLASTICSCM_SUBFOLDER);
}
const string PLASTICSCM_FOLDER = "PlasticSCM5";
const string PLASTICSCM_SUBFOLDER = "client";
class Plastic
{
internal const string GUI_WINDOWS = "plastic.exe";
internal const string LEGACY_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/PlasticSCM";
internal const string NEW_GUI_MACOS = "/Applications/PlasticSCM.app/Contents/MacOS/macplasticx";
}
class Gluon
{
internal const string GUI_WINDOWS = "gluon.exe";
internal const string LEGACY_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/Gluon";
internal const string NEW_GUI_MACOS = "/Applications/Gluon.app/Contents/MacOS/macgluonx";
}
}
} |