OnFileFailure() public method

Fires the file failure handler delegate.
public OnFileFailure ( string file, Exception e ) : bool
file string The file causing the failure.
e System.Exception The exception for this failure.
return bool
コード例 #1
0
ファイル: FastZip.cs プロジェクト: Bectinced-aeN/vrcsdk
 private void ProcessFile(object sender, ScanEventArgs e)
 {
     if (events_ != null && events_.ProcessFile != null)
     {
         events_.ProcessFile(sender, e);
     }
     if (e.ContinueRunning)
     {
         try
         {
             using (FileStream stream = File.Open(e.Name, FileMode.Open, FileAccess.Read, FileShare.Read))
             {
                 ZipEntry entry = entryFactory_.MakeFileEntry(e.Name);
                 outputStream_.PutNextEntry(entry);
                 AddFileContents(e.Name, stream);
             }
         }
         catch (Exception e2)
         {
             if (events_ == null)
             {
                 continueRunning_ = false;
                 throw;
             }
             continueRunning_ = events_.OnFileFailure(e.Name, e2);
         }
     }
 }
コード例 #2
0
 private void ProcessFile(object sender, ScanEventArgs e)
 {
     if (events_ != null && events_.ProcessFile != null)
     {
         events_.ProcessFile(sender, e);
     }
     if (!e.ContinueRunning)
     {
         return;
     }
     try
     {
         FileStream val = File.Open(e.Name, (FileMode)3, (FileAccess)1, (FileShare)1);
         try
         {
             ZipEntry entry = entryFactory_.MakeFileEntry(e.Name);
             outputStream_.PutNextEntry(entry);
             AddFileContents(e.Name, (Stream)(object)val);
         }
         finally
         {
             ((global::System.IDisposable)val)?.Dispose();
         }
     }
     catch (global::System.Exception e2)
     {
         if (events_ != null)
         {
             continueRunning_ = events_.OnFileFailure(e.Name, e2);
             return;
         }
         continueRunning_ = false;
         throw;
     }
 }
コード例 #3
0
        void ExtractEntry(ZipEntry entry)
        {
            bool   doExtraction = entry.IsCompressionMethodSupported();
            string targetName   = entry.Name;

            if (doExtraction)
            {
                if (entry.IsFile)
                {
                    targetName = extractNameTransform_.TransformFile(targetName);
                }
                else if (entry.IsDirectory)
                {
                    targetName = extractNameTransform_.TransformDirectory(targetName);
                }

                doExtraction = !((targetName == null) || (targetName.Length == 0));
            }

            // TODO: Fire delegate/throw exception were compression method not supported, or name is invalid?

            string dirName = null;

            if (doExtraction)
            {
                if (entry.IsDirectory)
                {
                    dirName = targetName;
                }
                else
                {
                    dirName = Path.GetDirectoryName(Path.GetFullPath(targetName));
                }
            }

            if (doExtraction && !Directory.Exists(dirName))
            {
                if (!entry.IsDirectory || CreateEmptyDirectories)
                {
                    try {
                        Directory.CreateDirectory(dirName);
                    }
                    catch (Exception ex) {
                        doExtraction = false;
                        if (events_ != null)
                        {
                            if (entry.IsDirectory)
                            {
                                continueRunning_ = events_.OnDirectoryFailure(targetName, ex);
                            }
                            else
                            {
                                continueRunning_ = events_.OnFileFailure(targetName, ex);
                            }
                        }
                        else
                        {
                            continueRunning_ = false;
                            throw;
                        }
                    }
                }
            }

            if (doExtraction && entry.IsFile)
            {
                ExtractFileEntry(entry, targetName);
            }
        }