示例#1
0
        /// <summary>
        /// Searches the archive to see if the specified file exists.
        /// </summary>
        public override bool FileExists(string filename)
        {
            string         path   = Path.GetDirectoryName(filename);
            FileTableEntry folder = fileTable.GetEntry(path, EntryType.Folder);

            if (folder == null)
            {
                return(false);
            }

            return(folder.GetChildren(new NameFilter(Path.GetFileName(filename)),
                                      new EntryTypeFilter(EntryType.File), DataFilter).Count > 0);
        }
示例#2
0
        public override string[] GetFileList(string path, string extension, bool recursive)
        {
            // Make sure that the path we are looking in exists.
            FileTableEntry folder = fileTable.GetEntry(path, EntryType.Folder);

            if (folder == null)
            {
                return(new string[0]);
            }

            List <FileTableEntry> entries = folder.GetChildren(recursive,
                                                               new ExtensionFilter(extension), new EntryTypeFilter(EntryType.File), DataFilter);

            return(FileTableEntry.EntriesToPaths(entries.ToArray()));
        }
示例#3
0
        public override string[] GetFolderList(string path)
        {
            // TEST CODE ::: Writes (supposedly) all entries in the filetable to a txt file.
            //List<FileTableEntry> test = fileTable.RootEntry.GetChildren(true);
            //System.IO.StreamWriter writer = new StreamWriter("C:\\test.txt");
            //foreach (FileTableEntry testEntry in test)
            //  writer.WriteLine(testEntry.FullPath + " - " + Enum.GetName(typeof(EntryType), testEntry.EntryType));
            //writer.Close();

            // Make sure that the path we are looking in exists.
            FileTableEntry folder = fileTable.GetEntry(path, EntryType.Folder);

            if (folder == null)
            {
                return(new string[0]);
            }

            // Get the results.
            List <IEntryFilter> filters = new List <IEntryFilter>();

            filters.Add(new EntryTypeFilter(EntryType.Folder));

            // Apply the proper filters based on the constraint.
            if (resultConstraint == ResultConstraint.ExistingFiles)
            {
                filters.Add(new ContainsFilesFilter());
            }
            if (resultConstraint == ResultConstraint.MissingFiles)
            {
                filters.Add(new ContainsMissingFilesFilter());
            }

            // Get the results.
            List <FileTableEntry> entries = folder.GetChildren(filters.ToArray());

            return(FileTableEntry.EntriesToPaths(entries.ToArray()));
        }
示例#4
0
        /// <summary>
        /// Returns a boolean indicating if the specified entry matches the filter's criteria.
        /// </summary>
        public bool Match(FileTableEntry entry)
        {
            List <FileTableEntry> files = entry.GetChildren(true, new EntryTypeFilter(EntryType.File), new HasNoDataFilter());

            return(files.Count > 0);
        }