public static PathFilter create(string path) { while (path.EndsWith("/")) path = path.Slice(0, path.Length - 1); if (path.Length == 0) throw new ArgumentException("Empty path not permitted."); return new PathFilter(path); }
/** * Create a collection of path filters from Java strings. * <para /> * Path strings are relative to the root of the repository. If the user's * input should be assumed relative to a subdirectory of the repository the * caller must prepend the subdirectory's path prior to creating the filter. * <para /> * Path strings use '/' to delimit directories on all platforms. * <para /> * Paths may appear in any order within the collection. Sorting may be done * internally when the group is constructed if doing so will improve path * matching performance. * * @param paths * the paths to test against. Must have at least one entry. * @return a new filter for the list of paths supplied. */ public static TreeFilter createFromStrings(IEnumerable <string> paths) { if (paths.Count() == 0) { throw new ArgumentException("At least one path is required."); } PathFilter[] p = new PathFilter[paths.Count()]; int i = 0; foreach (string s in paths) { p[i++] = PathFilter.create(s); } return(create(p)); }