OpenBve.ManagedContent.IsInstalledPackageProtected C# (CSharp) Méthode

IsInstalledPackageProtected() static private méthode

Checks whether the specified package is installed and protected from modification or deletion.
static private IsInstalledPackageProtected ( string package ) : bool
package string The package name.
Résultat bool
        internal static bool IsInstalledPackageProtected(string package)
        {
            foreach (string lookupDirectory in Program.FileSystem.ManagedContentFolders) {
                string packageDirectory = OpenBveApi.Path.CombineDirectory(lookupDirectory, package);
                if (Directory.Exists(packageDirectory)) {
                    string file = OpenBveApi.Path.CombineFile(packageDirectory, "package.cfg");
                    if (File.Exists(file)) {
                        string[] lines = File.ReadAllLines(file, Encoding.UTF8);
                        for (int j = 0; j < lines.Length; j++) {
                            lines[j] = lines[j].Trim();
                            int equals = lines[j].IndexOf('=');
                            if (equals >= 0) {
                                string key = lines[j].Substring(0, equals).TrimEnd();
                                if (key.Equals("protected", StringComparison.OrdinalIgnoreCase)) {
                                    string value = lines[j].Substring(equals + 1).TrimStart();
                                    if (value.Equals("true", StringComparison.OrdinalIgnoreCase)) {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }