A game about forced loneliness, made by TACStudios
1using System.IO;
2using Codice.Client.Common;
3using Codice.CM.Common;
4using PlasticGui;
5
6namespace Unity.PlasticSCM.Editor
7{
8 internal static class FindWorkspace
9 {
10 internal static bool HasWorkspace(string path)
11 {
12 string wkPath = PathForApplicationPath(path);
13
14 return !string.IsNullOrEmpty(wkPath);
15 }
16
17 internal static string PathForApplicationPath(string path)
18 {
19 return FindWorkspacePath(path, ClientConfig.Get().GetWkConfigDir());
20 }
21
22 internal static WorkspaceInfo InfoForApplicationPath(string path, IPlasticAPI plasticApi)
23 {
24 string wkPath = PathForApplicationPath(path);
25
26 if (string.IsNullOrEmpty(wkPath))
27 return null;
28
29 return plasticApi.GetWorkspaceFromPath(wkPath);
30 }
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
39 path = Path.GetDirectoryName(path);
40 }
41
42 return null;
43 }
44 }
45}