示例#1
0
        private bool process_error(string info, Exception ex)
        {
            if ((opts & ArchiveExtractOptions.SupressExceptions) == ArchiveExtractOptions.SupressExceptions)
            {
                return(true);
            }

            return(Messages.ShowExceptionContinue(ex, info));
        }
示例#2
0
        private bool process_errors(string info, Exception ex)
        {
            if ((options & MoveEngineOptions.SupressErrors) == MoveEngineOptions.SupressErrors)
            {
                return(true);
            }

            return(Messages.ShowExceptionContinue(ex, info));
        }
示例#3
0
 private bool process_error(string info, Exception ex)
 {
     if (opts.SupressErrors)
     {
         return(true);
     }
     else
     {
         return(Messages.ShowExceptionContinue(ex, info));
     }
 }
示例#4
0
 /// <summary>
 /// returns continue or abort all job
 /// </summary>
 /// <param name="info"></param>
 /// <param name="ex"></param>
 /// <returns></returns>
 protected bool process_error(string info, Exception ex)
 {
     if ((options & CopyEngineOptions.SupressErrors) == CopyEngineOptions.SupressErrors)
     {
         return(true);
     }
     else
     {
         return(Messages.ShowExceptionContinue(ex, info));
     }
 }
 private bool process_errors(string info, Exception ex)
 {
     return(Messages.ShowExceptionContinue(ex, info));
 }
示例#6
0
        private void add_to_zip(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other)
        {
            var main_window = (mainForm)Program.MainWindow;

            try
            {
                //this is sync operation
                var zd = (ZipDirectory)e_other.ItemCollection;
                var dl = (DirectoryList)e_current.ItemCollection;

                //show add zip dialog
                var dialog = new ArchiveAddDialog();
                dialog.Text = Options.GetLiteral(Options.LANG_ARCHIVE_ADD);
                dialog.textBoxSourceMask.Text = "*";
                dialog.ArchiveAddOptions      = Options.ArchiveAddOptions;
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                var options = dialog.ArchiveAddOptions;
                Options.ArchiveAddOptions = options;

                //notify main window
                main_window.NotifyLongOperation(Options.GetLiteral(Options.LANG_CREATING_FILE_LIST_TO_ARCHIVE), true);

                //create file list to add (only files with path)
                var one_file_list = new string[0];
                var root_paths    = new List <string>();
                var file_list     = new List <string>();
                if (e_current.SelectedIndices.Length == 0)
                {
                    if (dl[e_current.FocusedIndex].FileName == "..")
                    {
                        Messages.ShowMessage(Options.GetLiteral(Options.LANG_WRONG_SOURCE));
                        return;
                    }
                    root_paths.Add(dl[e_current.FocusedIndex].FullName);
                }
                else
                {
                    for (var i = 0; i < e_current.SelectedIndices.Length; i++)
                    {
                        root_paths.Add(dl[e_current.SelectedIndices[i]].FullName);
                    }
                }
                foreach (var one_path in root_paths)
                {
                    if ((Directory.Exists(one_path)) && ((options & ArchiveAddOptions.Recursive) == ArchiveAddOptions.Recursive))
                    {
                        one_file_list = Directory.GetFiles(one_path, dialog.textBoxSourceMask.Text, SearchOption.AllDirectories);
                    }
                    else if ((File.Exists(one_path)) && (Wildcard.Match(dialog.textBoxSourceMask.Text, one_path)))
                    {
                        one_file_list = new string[] { one_path };
                    }
                    else
                    {
                        one_file_list = new string[0];
                    }
                    file_list.AddRange(one_file_list);
                }

                //call ZipFile.BeginUpdate
                var zf = zd.ZipFile;


                //for each source list item:
                //create zip file name from real file path, trimmed from dl current directory
                //call ZipFile.Add
                //notify main window
                var current_dir = dl.DirectoryPath;
                var zip_path    = string.Empty;
                var zip_index   = 0;
                foreach (var one_file in file_list)
                {
                    try
                    {
                        zip_path = one_file.Substring(current_dir.Length);
                        if (zd.CurrentZipDirectory != string.Empty)
                        {
                            zip_path = zd.CurrentZipDirectory + "/" + zip_path;
                        }
                        zip_path = ZipEntry.CleanName(zip_path);

                        //check for exist
                        zip_index = zf.FindEntry(zip_path, true);
                        if (zip_index != -1)
                        {
                            //entry with same name already exists
                            if ((options & ArchiveAddOptions.NeverRewrite) == ArchiveAddOptions.NeverRewrite)
                            {
                                //skip
                                continue;
                            }
                            if ((options & ArchiveAddOptions.RewriteIfSourceNewer) == ArchiveAddOptions.RewriteIfSourceNewer)
                            {
                                //check mod date
                                if (File.GetLastWriteTime(one_file) < zf[zip_index].DateTime)
                                {
                                    continue;
                                }
                                else
                                {
                                    //remove entry
                                    zf.BeginUpdate();
                                    zf.Delete(zf[zip_index]);
                                    zf.CommitUpdate();
                                }
                            }
                            if ((options & ArchiveAddOptions.RewriteAlways) == ArchiveAddOptions.RewriteAlways)
                            {
                                zf.BeginUpdate();
                                zf.Delete(zf[zip_index]);
                                zf.CommitUpdate();
                            }
                        }

                        //open source file
                        main_window.NotifyLongOperation
                            (string.Format
                                (Options.GetLiteral(Options.LANG_ARCHIVING_0_1),
                                one_file,
                                zip_path),
                            true);
                        InternalStreamSource static_source = null;
                        try
                        {
                            //TODO избавиться от флага SaveAttributes
                            //будем всегда сохранять - DONE
                            zf.BeginUpdate();
                            zf.Add(one_file, zip_path);
                            main_window.NotifyLongOperation(Options.GetLiteral(Options.LANG_COMMIT_ARCHIVE_UPDATES), true);
                            zf.CommitUpdate();
                        }
                        catch (Exception ex)
                        {
                            if ((options & ArchiveAddOptions.SupressErrors) != ArchiveAddOptions.SupressErrors)
                            {
                                var err_message = string.Format
                                                      (Options.GetLiteral(Options.LANG_FAILED_ARCHIVE_0),
                                                      zip_path);
                                if (Messages.ShowExceptionContinue(ex, err_message))
                                {
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        finally
                        {
                            if (static_source != null)
                            {
                                static_source.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if ((options & ArchiveAddOptions.SupressErrors) != ArchiveAddOptions.SupressErrors)
                        {
                            var err_message = string.Format
                                                  (Options.GetLiteral(Options.LANG_FAILED_ARCHIVE_0),
                                                  zip_path);
                            if (Messages.ShowExceptionContinue(ex, err_message))
                            {
                                continue;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }//end of foreach

                //Refill zd
                zd.Refill();

                //notify main window when done
            }
            catch (Exception ex)
            {
                Messages.ShowException(ex);
            }
            finally
            {
                main_window.NotifyLongOperation("Done", false);
            }
        }