Skip to content

Commit

Permalink
M#0003296
Browse files Browse the repository at this point in the history
Из диалога создания архива исключаются однофайловые форматы, если архивируются несколько файлов или есть директории.
  • Loading branch information
w17 committed Dec 27, 2016
1 parent 0c992f2 commit 8f037ad
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
1 change: 1 addition & 0 deletions plugins/arclite/archive.cpp
Expand Up @@ -27,6 +27,7 @@ DEFINE_ARC_ID(rar, "\x03")
DEFINE_ARC_ID(split, "\xEA")
DEFINE_ARC_ID(wim, "\xE6")
DEFINE_ARC_ID(tar, "\xEE")
DEFINE_ARC_ID(SWFc, "\xD8")

#undef DEFINE_ARC_ID

Expand Down
8 changes: 6 additions & 2 deletions plugins/arclite/archive.hpp
Expand Up @@ -13,6 +13,7 @@ extern const ArcType c_rar;
extern const ArcType c_split;
extern const ArcType c_wim;
extern const ArcType c_tar;
extern const ArcType c_SWFc;

extern const wchar_t* c_method_copy;
extern const wchar_t* c_method_lzma;
Expand Down Expand Up @@ -221,7 +222,7 @@ class Archive: public enable_shared_from_this<Archive> {

HRESULT copy_prologue(IOutStream *out_stream);

// archive contents
// archive contents
public:
UInt32 num_indices;
FileList file_list;
Expand Down Expand Up @@ -284,5 +285,8 @@ class Archive: public enable_shared_from_this<Archive> {
AttrList get_attr_list(UInt32 item_index);

public:
Archive() : base_stream(nullptr), update_props_defined(false) {}
Archive()
: base_stream(nullptr), num_indices(0)
, solid(false), encrypted(false), update_props_defined(false), has_crc(false)
{}
};
4 changes: 4 additions & 0 deletions plugins/arclite/changelog
@@ -1,3 +1,7 @@
w17 27.12.2016 21:17:38 +0300 - build 245

1. 0003296: 7z.dll can only add/make archive 7z, zip, wim and tar

w17 27.12.2016 20:42:33 +0300 - build 244

1. 0003298: Difference 7z archive size result between compression level ultra - normal - max
Expand Down
2 changes: 1 addition & 1 deletion plugins/arclite/options.hpp
Expand Up @@ -13,7 +13,7 @@ struct Options {
// update
wstring update_arc_format_name;
unsigned update_level;
wstring update_levels; // for example: '7z=7;zip=5;bzip2=9;xz=5;SWFc=5;wim=0;tar=0;gzip=5'
wstring update_levels; // for example: '7z=7;zip=5;bzip2=9;xz=5;wim=0;tar=0;gzip=5'
wstring update_method;
bool update_solid;
wstring update_advanced;
Expand Down
8 changes: 6 additions & 2 deletions plugins/arclite/plugin.cpp
Expand Up @@ -475,6 +475,7 @@ class Plugin {
return;
UpdateOptions options;
bool new_arc = !archive->is_open();
bool multifile = items_number > 1 || (items_number == 1 && (panel_items[0].FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
if (!new_arc && !archive->updatable()) {
FAIL_MSG(Far::get_msg(MSG_ERROR_NOT_UPDATABLE));
}
Expand Down Expand Up @@ -534,7 +535,7 @@ class Plugin {

options.ignore_errors = g_options.update_ignore_errors;

bool res = update_dialog(new_arc, options, g_profiles);
bool res = update_dialog(new_arc, multifile, options, g_profiles);
if (!res)
FAIL(E_ABORT);
if (ArcAPI::formats().count(options.arc_type) == 0)
Expand Down Expand Up @@ -616,9 +617,12 @@ class Plugin {
vector<wstring> file_list;
file_list.reserve(panel_info.SelectedItemsNumber);
wstring src_path = Far::get_panel_dir(PANEL_ACTIVE);
bool multifile = false;
for (size_t i = 0; i < panel_info.SelectedItemsNumber; i++) {
Far::PanelItem panel_item = Far::get_selected_panel_item(PANEL_ACTIVE, i);
file_list.push_back(panel_item.file_name);
if (file_list.size() > 1 || (panel_item.file_attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
multifile = true;
}
if (file_list.empty())
FAIL(E_ABORT);
Expand Down Expand Up @@ -652,7 +656,7 @@ class Plugin {
options.ignore_errors = g_options.update_ignore_errors;
options.append_ext = g_options.update_append_ext;

bool res = update_dialog(true, options, g_profiles);
bool res = update_dialog(true, multifile, options, g_profiles);
if (!res)
FAIL(E_ABORT);
if (ArcAPI::formats().count(options.arc_type) == 0)
Expand Down
2 changes: 1 addition & 1 deletion plugins/arclite/project.ini
Expand Up @@ -2,4 +2,4 @@
MODULE = arclite
VER_MAJOR = 3
VER_MINOR = 0
VER_BUILD = 244
VER_BUILD = 245
18 changes: 12 additions & 6 deletions plugins/arclite/ui.cpp
Expand Up @@ -10,6 +10,10 @@
#include "options.hpp"
#include <algorithm>

static bool is_single_file_format(const ArcType& arc_ty) {
return arc_ty == c_bzip2 || arc_ty == c_gzip || arc_ty == c_xz || arc_ty == c_SWFc;
}

wstring get_error_dlg_title() {
return Far::get_msg(MSG_PLUGIN_NAME);
}
Expand Down Expand Up @@ -658,6 +662,7 @@ class UpdateDialog: public Far::Dialog {
};

bool new_arc;
bool multifile;
wstring default_arc_name;
vector<ArcType> main_formats;
vector<ArcType> other_formats;
Expand Down Expand Up @@ -1225,9 +1230,10 @@ class UpdateDialog: public Far::Dialog {
}

public:
UpdateDialog(bool new_arc, UpdateOptions& options, UpdateProfiles& profiles):
UpdateDialog(bool new_arc, bool multifile, UpdateOptions& options, UpdateProfiles& profiles):
Far::Dialog(Far::get_msg(new_arc ? MSG_UPDATE_DLG_TITLE_CREATE : MSG_UPDATE_DLG_TITLE), &c_update_dialog_guid, c_client_xs, L"Update"),
new_arc(new_arc),
multifile(multifile),
default_arc_name(options.arc_path),
options(options),
profiles(profiles),
Expand Down Expand Up @@ -1276,7 +1282,7 @@ class UpdateDialog: public Far::Dialog {
spacer(1);
const ArcFormats& arc_formats = ArcAPI::formats();
for (unsigned i = 0; i < ARRAYSIZE(c_archive_types); i++) {
ArcFormats::const_iterator arc_iter = arc_formats.find(c_archive_types[i].value);
const auto arc_iter = arc_formats.find(c_archive_types[i].value);
if (arc_iter != arc_formats.end() && arc_iter->second.updatable) {
bool first = main_formats.size() == 0;
if (!first)
Expand All @@ -1292,8 +1298,8 @@ class UpdateDialog: public Far::Dialog {
unsigned other_format_index = 0;
bool found = false;
for (ArcFormats::const_iterator arc_iter = arc_formats.begin(); arc_iter != arc_formats.end(); arc_iter++) {
if (arc_iter->second.updatable) {
vector<ArcType>::const_iterator main_type = find(main_formats.begin(), main_formats.end(), arc_iter->first);
if (arc_iter->second.updatable && (!multifile || !is_single_file_format(arc_iter->first))) {
const auto main_type = find(main_formats.begin(), main_formats.end(), arc_iter->first);
if (main_type == main_formats.end()) {
other_formats.push_back(arc_iter->first);
format_names.push_back(arc_iter->second.name);
Expand Down Expand Up @@ -1422,8 +1428,8 @@ class UpdateDialog: public Far::Dialog {
}
};

bool update_dialog(bool new_arc, UpdateOptions& options, UpdateProfiles& profiles) {
return UpdateDialog(new_arc, options, profiles).show();
bool update_dialog(bool new_arc, bool multifile, UpdateOptions& options, UpdateProfiles& profiles) {
return UpdateDialog(new_arc, multifile, options, profiles).show();
}


Expand Down
2 changes: 1 addition & 1 deletion plugins/arclite/ui.hpp
Expand Up @@ -24,7 +24,7 @@ bool extract_dialog(ExtractOptions& options);

void show_error_log(const ErrorLog& error_log);

bool update_dialog(bool new_arc, UpdateOptions& options, UpdateProfiles& profiles);
bool update_dialog(bool new_arc, bool multifile, UpdateOptions& options, UpdateProfiles& profiles);

struct PluginSettings {
bool handle_create;
Expand Down

0 comments on commit 8f037ad

Please sign in to comment.