MacOSConfigWorkaround.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.IO;
  2. using Codice.Client.Common;
  3. using Codice.Utils;
  4. namespace Unity.PlasticSCM.Editor.Views.Welcome
  5. {
  6. class MacOSConfigWorkaround
  7. {
  8. /* In macOS there is no way to pass a parameter
  9. * to the PKG installer to avoid launching
  10. * Plastic at the end of the installation process.
  11. * As a workaround, we can create an empty client.conf in
  12. * the user config folder. This way the installer skips
  13. * launching Plastic at the end of the installation process.
  14. * see /01plastic/install/mac/macplastic/Scripts/postinstall
  15. * Then, we delete the client.conf file if we created it */
  16. internal void CreateClientConfigIfNeeded()
  17. {
  18. if (!PlatformIdentifier.IsMac())
  19. return;
  20. string clientConfFile = ConfigFileLocation.GetConfigFilePath(
  21. ClientConfig.CLIENT_CONFIG_FILE_NAME);
  22. if (File.Exists(clientConfFile))
  23. return;
  24. File.Create(clientConfFile).Close();
  25. mClientConfigCreated = true;
  26. }
  27. internal void DeleteClientConfigIfNeeded()
  28. {
  29. if (!mClientConfigCreated)
  30. return;
  31. string clientConfFile = ConfigFileLocation.GetConfigFilePath(
  32. ClientConfig.CLIENT_CONFIG_FILE_NAME);
  33. File.Delete(clientConfFile);
  34. }
  35. bool mClientConfigCreated;
  36. }
  37. }