コード例 #1
0
ファイル: Main.cs プロジェクト: zhaofangzhou/SharpZipLib
 void ListDir(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Console.WriteLine("Dir:{0}", e.Name);
     }
 }
コード例 #2
0
 private void _fileSystemVisitor_FileFinded(object sender, DirectoryEventArgs e)
 {
     if (e.ItemInformation.Contains(SKIPPED_NON_FILTERED_FILE))
     {
         e.Skip = true;
     }
 }
コード例 #3
0
 private void _fileSystemVisitor_DirectoryFinded1(object sender, DirectoryEventArgs e)
 {
     if (e.ItemInformation.Contains(SKIPPED_NON_FILTERED_FOLDER))
     {
         e.Break = true;
     }
 }
コード例 #4
0
ファイル: Main.cs プロジェクト: zhaofangzhou/SharpZipLib
 void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Console.WriteLine(e.Name);
     }
 }
コード例 #5
0
ファイル: zf.cs プロジェクト: saintsrowmods/SaintsRow2Tools
 /// <summary>
 /// Callback for adding a new directory.
 /// </summary>
 /// <param name="sender">The scanner calling this delegate.</param>
 /// <param name="args">The event arguments.</param>
 /// <remarks>Directories are only added if they are empty and
 /// the user has specified that empty directories are to be added.</remarks>
 void ProcessDirectory(object sender, DirectoryEventArgs args)
 {
     if (!args.HasMatchingFiles && addEmptyDirectoryEntries_)
     {
         activeZipFile_.AddDirectory(args.Name);
     }
 }
コード例 #6
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles)
     {
         Log.LogMessage(Properties.Resources.UnzipExtracted, e.Name);
     }
 }
コード例 #7
0
 /// <summary>
 /// Raises the ProcessDirectoryEvent.
 /// </summary>
 /// <param name="directory">The directory for this event.</param>
 /// <param name="hasMatchingFiles">Flag indicating if directory has matching files as determined by the current filter.</param>
 public void OnProcessDirectory(string directory, bool hasMatchingFiles)
 {
     if (ProcessDirectory != null)
     {
         DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles);
         ProcessDirectory(this, args);
     }
 }
コード例 #8
0
 private void ReportProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (OnProcessDirectory != null)
     {
         FastZipArchiveDirectoryEventArgs args = new FastZipArchiveDirectoryEventArgs(e);
         OnProcessDirectory(this, args);
     }
 }
コード例 #9
0
        /// <summary>
        ///   Raise the ProcessDirectory event.
        /// </summary>
        /// <param name = "directory">The directory name.</param>
        /// <param name = "hasMatchingFiles">Flag indicating if the directory has matching files.</param>
        private void OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            ProcessDirectoryHandler handler = ProcessDirectory;

            if (handler != null)
            {
                var args = new DirectoryEventArgs(directory, hasMatchingFiles);
                handler(this, args);
                alive_ = args.ContinueRunning;
            }
        }
コード例 #10
0
ファイル: DirectoryView.cs プロジェクト: cixonline/cixreader
 /// <summary>
 /// Callback from the directory task update when new directory data has been loaded
 /// from the server. In this case we're just interested in updating the progress bar until
 /// we get to 100% at which point we stop and update the UI.
 /// </summary>
 private void OnDirectoryChanged(object sender, DirectoryEventArgs args)
 {
     Platform.UIThread(this, delegate
     {
         if (args.CategoryName != null && args.CategoryName == _currentCategory.Name)
         {
             _items = new List <DirForum>(CIX.DirectoryCollection.AllForumsInCategory(_currentCategory.Name));
             SortItems();
         }
     });
 }
コード例 #11
0
ファイル: FastZip.cs プロジェクト: hashem30/Study
        /// <summary>
        /// Fires the <see cref="ProcessDirectory">process directory</see> delegate.
        /// </summary>
        /// <param name="directory">The directory being processed.</param>
        /// <param name="hasMatchingFiles">Flag indicating if the directory has matching files as determined by the current filter.</param>
        /// <returns>A <see cref="bool"/> of true if the operation should continue; false otherwise.</returns>
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;

            if (ProcessDirectory != null)
            {
                DirectoryEventArgs args = new DirectoryEventArgs(directory, hasMatchingFiles);
                ProcessDirectory(this, args);
                result = args.ContinueRunning;
            }
            return(result);
        }
コード例 #12
0
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool continueRunning = true;

            if (this.ProcessDirectory != null)
            {
                DirectoryEventArgs e = new DirectoryEventArgs(directory, hasMatchingFiles);
                this.ProcessDirectory(this, e);
                continueRunning = e.ContinueRunning;
            }
            return(continueRunning);
        }
コード例 #13
0
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;
            ProcessDirectoryHandler processDirectory = ProcessDirectory;

            if (processDirectory != null)
            {
                DirectoryEventArgs directoryEventArgs = new DirectoryEventArgs(directory, hasMatchingFiles);
                processDirectory(this, directoryEventArgs);
                result = directoryEventArgs.ContinueRunning;
            }
            return(result);
        }
コード例 #14
0
        /// <summary>
        /// Fires the <see cref="ProcessDirectory">process directory</see> delegate.
        /// </summary>
        /// <param name="directory">The directory being processed.</param>
        /// <param name="hasMatchingFiles">Flag indicating if the directory has matching files as determined by the current filter.</param>
        /// <returns>A <see cref="bool"/> of true if the operation should continue; false otherwise.</returns>
        public bool OnProcessDirectory(string directory, bool hasMatchingFiles)
        {
            bool result = true;
            EventHandler <DirectoryEventArgs> handler = ProcessDirectory;

            if (handler != null)
            {
                var args = new DirectoryEventArgs(directory, hasMatchingFiles);
                handler(this, args);
                result = args.ContinueRunning;
            }
            return(result);
        }
コード例 #15
0
        private void TreeViewerOnDirectorySelected(object sender, DirectoryEventArgs args)
        {
            var item    = args.Item;
            var builder = new StringBuilder();

            builder.AppendLine(item.Path);
            var statistics = item.Statistics;

            builder.AppendLine($"Recog: {statistics.RecogImageCount} / markup: {statistics.MarkupImageCount} / total: {statistics.TotalImageCount}.");
            foreach (var stencil in statistics.Stencils.OrderBy(p => p.Key))
            {
                builder.AppendLine($"{stencil.Key}: markup: {stencil.Value.MarkupPlateCount}, total: {stencil.Value.TotalPlateCount}");
            }
            _txtDirectoryInfo.Text = builder.ToString();
        }
コード例 #16
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && this.createEmptyDirectories)
     {
         if (this.events != null)
         {
             this.events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.Name != this.sourceDirectory)
         {
             ZipEntry entry = new ZipEntry(this.nameTransform.TransformDirectory(e.Name));
             this.outputStream.PutNextEntry(entry);
         }
     }
 }
コード例 #17
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && CreateEmptyDirectories)
     {
         if (_events != null)
         {
             _events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.ContinueRunning && (e.Name != _sourceDirectory))
         {
             ZipEntry entry = _entryFactory.MakeDirectoryEntry(e.Name);
             _outputStream.PutNextEntry(entry);
         }
     }
 }
コード例 #18
0
 private void ProcessDirectory(object sender, DirectoryEventArgs e)
 {
     if (!e.HasMatchingFiles && this.CreateEmptyDirectories)
     {
         if (this.events_ != null)
         {
             this.events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
         }
         if (e.ContinueRunning && e.Name != this.sourceDirectory_)
         {
             ZipEntry entry = this.entryFactory_.MakeDirectoryEntry(e.Name);
             this.outputStream_.PutNextEntry(entry);
         }
     }
 }
コード例 #19
0
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && CreateEmptyDirectories)
            {
                if (events_ != null)
                {
                    events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.Name != sourceDirectory_)
                {
                    ZipEntry entry = entryFactory_.MakeDirectoryEntry(e.Name);
                    outputStream_.PutNextEntry(entry);
                }
            }
        }
コード例 #20
0
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && createEmptyDirectories)
            {
                if (events != null)
                {
                    events.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.Name != sourceDirectory)
                {
                    string   cleanedName = nameTransform.TransformDirectory(e.Name);
                    ZipEntry entry       = new ZipEntry(cleanedName);
                    outputStream.PutNextEntry(entry);
                }
            }
        }
コード例 #21
0
ファイル: FastZip.cs プロジェクト: womandroid/cocos2d-xna
        void ProcessDirectory(object sender, DirectoryEventArgs e)
        {
            if (!e.HasMatchingFiles && CreateEmptyDirectories)
            {
                if (events_ != null)
                {
                    events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
                }

                if (e.ContinueRunning)
                {
                    if (e.Name != sourceDirectory_)
                    {
                        ZipEntry entry = entryFactory_.MakeDirectoryEntry(e.Name);
                    }
                }
            }
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: MikhailSamorukov/HomeTask1
        private static void SetToStateAgruments(DirectoryEventArgs e)
        {
            Console.WriteLine("Information: ");
            Console.WriteLine(e.ItemInformation);
            Console.WriteLine(new string('-', 50));
            Console.WriteLine("Do you want to continue?");
            Console.WriteLine("s - skip");
            Console.WriteLine("x - break");
            Console.WriteLine("other button - continue");
            var cki = Console.ReadKey();

            if (cki.KeyChar == 's')
            {
                e.Skip = true;
            }

            if (cki.KeyChar == 'x')
            {
                e.Break = true;
            }

            Console.WriteLine();
        }
コード例 #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
 {
     SendDirectory((Codec as IHasDirectory).CurrentDirectoryResult, e.DirectoryIsOnRoot);
 }
コード例 #24
0
 protected virtual void OnNotifyThatDirectoryPassedFilteringSuccessfully(DirectoryEventArgs e)
 {
     NotifyThatDirectoryPassedFilteringSuccessfully?.Invoke(this, e);
 }
コード例 #25
0
 protected virtual void OnNotifyThatDirectoryWasFounded(DirectoryEventArgs e)
 {
     NotifyThatDirectoryWasFounded?.Invoke(this, e);
 }
コード例 #26
0
 protected virtual void OnNotifyThatDirectoryNotFiltered(DirectoryEventArgs e)
 {
     NotifyThatDirectoryNotFiltered?.Invoke(this, e);
 }
コード例 #27
0
        public IEnumerable <string> Explore(string directoryPath)
        {
            OnNotifyAboutStartingOfExplore(new DirectoryEventArgs
            {
                DirectoryInfo = new DirectoryInfo(directoryPath)
            });

            var researchDirectories = new Queue <string>();

            researchDirectories.Enqueue(directoryPath);

            while (researchDirectories.Any())
            {
                var currentDirectory = researchDirectories.Dequeue();

                var foundDirectories = Directory.EnumerateDirectories(currentDirectory).Select(d => new DirectoryInfo(d));

                foreach (var directory in foundDirectories)
                {
                    var directoryEventArgs = new DirectoryEventArgs {
                        DirectoryInfo = directory
                    };

                    OnNotifyThatDirectoryWasFounded(directoryEventArgs);

                    if (DirectoryPredicate != null && !DirectoryPredicate(directory))
                    {
                        OnNotifyThatDirectoryNotFiltered(directoryEventArgs);
                        continue;
                    }

                    OnNotifyThatDirectoryPassedFilteringSuccessfully(directoryEventArgs);

                    switch (directoryEventArgs.FurtherAction)
                    {
                    case FurtherAction.Skip:
                        continue;

                    case FurtherAction.Stop:
                        yield break;
                    }

                    yield return(directory.Name);

                    researchDirectories.Enqueue(directory.FullName);
                }

                var foundFiles = Directory.EnumerateFiles(currentDirectory).Select(f => new FileInfo(f));

                foreach (var file in foundFiles)
                {
                    var fileEventArgs = new FileEventArgs {
                        FileInfo = file
                    };

                    OnNotifyThatFileWasFounded(fileEventArgs);

                    if (FilePredicate != null && !FilePredicate(file))
                    {
                        OnNotifyThatFileNotFiltered(fileEventArgs);
                        continue;
                    }

                    OnNotifyThatFilePassedFilteringSuccessfully(fileEventArgs);

                    switch (fileEventArgs.FurtherAction)
                    {
                    case FurtherAction.Skip:
                        continue;

                    case FurtherAction.Stop:
                        yield break;
                    }

                    yield return(file.Name);
                }
            }

            OnNotifyAboutFinishingOfExplore(new DirectoryEventArgs
            {
                DirectoryInfo = new DirectoryInfo(directoryPath)
            });
        }
コード例 #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void dir_DirectoryResultReturned(object sender, DirectoryEventArgs e)
 {
     RefreshDirectory();
 }
コード例 #29
0
 protected virtual void OnRaiseDirectoryFoundEvent(DirectoryEventArgs directoryEventArgs)
 {
     DirectoryFound?.Invoke(this, directoryEventArgs);
 }
コード例 #30
0
        /// <summary>
        /// Traversal of directory tree
        /// </summary>
        /// <param name="rootDirectory">Root to start traversal</param>
        /// <returns>IEnumerable of directorys'(or files') names</returns>
        public IEnumerable <string> WalkDirectoryTree(DirectoryInfo rootDirectory)
        {
            OnRaiseTraversalStart(new MessageEventArgs($"Traversal start: {rootDirectory}"));
            if (rootDirectory == null)
            {
                throw new ArgumentNullException($"{nameof(rootDirectory)} is required");
            }
            FileInfo[]      files;
            DirectoryInfo[] subDirectories;
            try
            {
                files          = rootDirectory.GetFiles("*.*");
                subDirectories = rootDirectory.GetDirectories();
            }
            catch (UnauthorizedAccessException)
            {
                throw new UnauthorizedAccessException($"You don't have permissions to enter directory {rootDirectory}");
            }

            foreach (FileInfo file in files)
            {
                FileEventArgs fileArgs = new FileEventArgs(file);
                OnRaiseFileFoundEvent(fileArgs);
                if (fileArgs.StopTraversal)
                {
                    yield break;
                }
                if (Filter(file.FullName))
                {
                    FileEventArgs nessesaryFileArgs = new FileEventArgs(file);
                    OnRaiseRequiredFileFoundEvent(nessesaryFileArgs);
                    if (nessesaryFileArgs.StopTraversal)
                    {
                        yield break;
                    }
                    if (!fileArgs.ExcludeFile && !nessesaryFileArgs.ExcludeFile)
                    {
                        yield return(file.FullName);
                    }
                }
            }

            foreach (DirectoryInfo directory in subDirectories)
            {
                DirectoryEventArgs directoryArgs = new DirectoryEventArgs(directory);
                OnRaiseDirectoryFoundEvent(directoryArgs);
                if (directoryArgs.StopTraversal)
                {
                    yield break;
                }
                if (Filter(directory.FullName))
                {
                    DirectoryEventArgs nessesaryDirectoryArgs = new DirectoryEventArgs(directory);
                    OnRaiseRequiredDirectoryFoundEvent(nessesaryDirectoryArgs);
                    if (nessesaryDirectoryArgs.StopTraversal)
                    {
                        yield break;
                    }
                    if (!directoryArgs.ExcludeDirectory && !nessesaryDirectoryArgs.ExcludeDirectory)
                    {
                        yield return(directory.FullName);

                        foreach (var item in WalkDirectoryTree(directory))
                        {
                            yield return(item);
                        }
                    }
                }
            }
            OnRaiseTraversalFinished(new MessageEventArgs($"Traversal finished"));
        }