Esempio n. 1
0
        public static UrlDir CreateDir(string url, UrlDir parent = null)
        {
            if (parent == null)
            {
                parent = CreateRoot();
            }
            else
            {
                UrlDir existingDir = parent.GetDirectory(url);
                if (existingDir != null)
                {
                    return(existingDir);
                }
            }

            UrlDir current = parent;

            foreach (string name in url.Split('/'))
            {
                UrlDir dir = CreateRoot();
                UrlDir__field__name.SetValue(dir, name);
                UrlDir__field__root.SetValue(dir, current.root);
                UrlDir__field__parent.SetValue(dir, current);

                current.children.Add(dir);
                current = dir;
            }

            return(current);
        }
Esempio n. 2
0
        private IEnumerable <string> CheckUnexpectedUrls()
        {
            UrlDir gameData = GameDatabase.Instance.root.children.First(dir => dir.type == UrlDir.DirectoryType.GameData);

            foreach (string unexpectedUrl in UNEXPECTED_URLS)
            {
                if (!(gameData.GetDirectory(unexpectedUrl) is UrlDir unexpectedDir))
                {
                    continue;
                }
                Debug.LogError("[ReStock] Found unexpected directory " + unexpectedDir.path);
                yield return($"Found unexpected directory, likely left over from an older version of KSP:\n" + unexpectedDir.path);
            }
        }