No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FindWorkspace.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.IO;
  2. using Codice.Client.Common;
  3. using Codice.CM.Common;
  4. using PlasticGui;
  5. namespace Unity.PlasticSCM.Editor
  6. {
  7. internal static class FindWorkspace
  8. {
  9. internal static bool HasWorkspace(string path)
  10. {
  11. string wkPath = PathForApplicationPath(path);
  12. return !string.IsNullOrEmpty(wkPath);
  13. }
  14. internal static string PathForApplicationPath(string path)
  15. {
  16. try
  17. {
  18. return FindWorkspacePath(path, ClientConfig.Get().GetWkConfigDir());
  19. }
  20. catch (NotConfiguredClientException)
  21. {
  22. return null;
  23. }
  24. }
  25. internal static WorkspaceInfo InfoForApplicationPath(string path, IPlasticAPI plasticApi)
  26. {
  27. string wkPath = PathForApplicationPath(path);
  28. if (string.IsNullOrEmpty(wkPath))
  29. return null;
  30. return plasticApi.GetWorkspaceFromPath(wkPath);
  31. }
  32. static string FindWorkspacePath(string path, string wkConfigDir)
  33. {
  34. while (!string.IsNullOrEmpty(path))
  35. {
  36. if (Directory.Exists(Path.Combine(path, wkConfigDir)))
  37. return path;
  38. path = Path.GetDirectoryName(path);
  39. }
  40. return null;
  41. }
  42. }
  43. }