/// <summary> /// Gets whether the specified file is ignored by the addon's ignore list. /// </summary> /// <param name="path">The file to check.</param> /// <returns>True if the addon is ignored, false if not.</returns> private bool IsIgnored(string path) { foreach (string pattern in Ignores) { if (Whitelist.Check(pattern, path)) { return(true); } } return(false); }
/// <summary> /// Adds the specified file from the local filesystem to the encapsulated addon. /// </summary> /// <param name="filename">The path of the file to add.</param> /// <exception cref="FileNotFoundException">Thrown if the specified file does not exist.</exception> /// <exception cref="IOException">Thrown if a problem happens with opening the file.</exception> /// <exception cref="ArgumentException">Happens if a file with the same path is already added.</exception> /// <exception cref="WhitelistException">The file is prohibited from storing by the global whitelist.</exception> /// <exception cref="IgnoredException">The file is prohibited from storing by the addon's ignore list.</exception> public void AddFile(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException("The specified file " + filename + " does not exist."); } // Prevent the need to read the contents of a file if it cannot be added. string path = Whitelist.GetMatchingString(filename); try { OpenAddon.CheckRestrictions(path); } catch (IgnoredException) { throw; } catch (WhitelistException) { throw; } catch (ArgumentException) { throw; } byte[] bytes; try { bytes = File.ReadAllBytes(filename); } catch (IOException) { throw; } AddFile(Whitelist.GetMatchingString(filename), bytes); }
/// <summary> /// Gets whether the specified file is allowed to be in GMAs by the global whitelist. /// </summary> /// <param name="path">The file to check.</param> /// <returns>True if the addon is allowed, false if not.</returns> private bool IsWhitelisted(string path) { return(Whitelist.Check(path.ToLowerInvariant())); }