Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiarc truncate name of archive #2434

Open
Zeroes1 opened this issue Oct 12, 2024 · 2 comments
Open

Multiarc truncate name of archive #2434

Zeroes1 opened this issue Oct 12, 2024 · 2 comments

Comments

@Zeroes1
Copy link

Zeroes1 commented Oct 12, 2024

FAR 2.6.3-2024-10-06-0b7aba4

Захотел заархивировать папку far2l
ShiftF1 far2l добавил дату 12.10.2024
far2l12.10.2024
выходной файл получается:
far2l12.10.7z
с tar.gz/zip тоже самое

@akruphi
Copy link
Contributor

akruphi commented Oct 13, 2024

Это где-то внутри PluginClass::PutFiles() из multiarc/src/arcput.cpp править надо, только сходу не вижу где именно портится:

// новый стиль диалога "Добавить к архиву"
//+----------------------------------------------------------------------------+
//| |
//| +---------------------------- Add to ZIP ----------------------------+ |
//| | Add to archive | |
//| | backup************************************************************�| |
//| | Select archiver Switches | |
//| | ZIP******************� *******************************************�| |
//| |--------------------------------------------------------------------| |
//| | Archive password Reenter password | |
//| | ******************************** ******************************** | |
//| |--------------------------------------------------------------------| |
//| | [ ] Delete files after archiving | |
//| | [ ] Exact archive filename | |
//| | [ ] Background | |
//| |--------------------------------------------------------------------| |
//| | [ Add ] [ Save settings ] [ Cancel ] | |
//| +--------------------------------------------------------------------+ |
//| |
//+----------------------------------------------------------------------------+
int PluginClass::PutFiles(struct PluginPanelItem *PanelItem, int ItemsNumber, int Move, int OpMode)
{
if (ItemsNumber == 0)
return 0;
std::string Command, AllFilesMask;
int ArcExitCode = 1;
BOOL OldExactState = Opt.AdvFlags.AutoResetExactArcName ? FALSE : Opt.AdvFlags.ExactArcName;
BOOL RestoreExactState = FALSE, NewArchive = TRUE;
struct PutDlgData pdd;
BOOL Ret = TRUE;
pdd.Self = this;
if (ArcPluginNumber == -1) {
std::string DefaultFormat = KeyFileReadSection(INI_LOCATION, INI_SECTION).GetString("DefaultFormat", "TARGZ");
if (!FormatToPlugin(DefaultFormat, ArcPluginNumber, ArcPluginType)) {
ArcPluginNumber = ArcPluginType = 0;
pdd.DefaultPluginNotFound = TRUE;
} else {
pdd.ArcFormat = DefaultFormat;
pdd.DefaultPluginNotFound = FALSE;
}
}
/* $ 14.02.2001 raVen
сброс галки "фоновая архивация" */
/* $ 13.04.2001 DJ
перенесен в более подходящее место */
Opt.UserBackground = 0;
/* DJ $ */
/* raVen $ */
Opt.PriorityClass = 2;
while (1) {
pdd.DefExt = KeyFileReadSection(INI_LOCATION, pdd.ArcFormat).GetString("DefExt");
if (pdd.DefExt.empty())
Ret = ArcPlugin->GetFormatName(ArcPluginNumber, ArcPluginType, pdd.ArcFormat, pdd.DefExt);
if (!Ret) {
Opt.PriorityClass = 2;
return 0;
}
const char *ArcHistoryName = "ArcName";
/*
г============================ Add to RAR ============================¬
¦ Add to archive ¦
¦ arcput �¦
¦ Switches ¦
¦ -md1024 -mm -m5 -s -rr -av �¦
¦--------------------------------------------------------------------¦
| Archive password Reenter password |
| ******************************** ******************************** |
¦--------------------------------------------------------------------¦
¦ [ ] Delete files after archiving Priority of process ¦
¦ [ ] Exact archive filename ******************** �¦
¦ [ ] Background |
¦--------------------------------------------------------------------¦
¦ [ Add ] [ Select archiver ] [ Save settings ] [ Cancel ] ¦
L====================================================================-
*/
struct InitDialogItem InitItems[] = {
/* 0*/ {DI_DOUBLEBOX, 3, 1, 72, 15, 0, 0, 0, 0, ""},
/* 1*/ {DI_TEXT, 5, 2, 0, 0, 0, 0, 0, 0, (char *)MAddToArc},
/* 2*/ {DI_EDIT, 5, 3, 70, 3, 1, (DWORD_PTR)ArcHistoryName, DIF_HISTORY, 0, ""},
//* 3*/{DI_TEXT,5,4,0,0,0,0,0,0,(char *)MAddSelect},
//* 4*/{DI_COMBOBOX,5,5,25,3,0,0,DIF_DROPDOWNLIST|DIF_LISTAUTOHIGHLIGHT|DIF_LISTNOAMPERSAND,0,""},
//* 5*/{DI_TEXT,28,4,0,0,0,0,0,0,(char *)MAddSwitches},
//* 6*/{DI_EDIT,28,5,70,3,0,0,DIF_HISTORY,0,""},
/* 3*/ {DI_TEXT, 5, 4, 0, 0, 0, 0, 0, 0, (char *)MAddSwitches},
/* 4*/ {DI_EDIT, 5, 5, 47, 3, 0, 0, DIF_HISTORY, 0, ""},
/* 5*/ {DI_TEXT, 50, 4, 0, 0, 0, 0, 0, 0, (char *)MAddSelect},
/* 6*/
{DI_COMBOBOX, 50, 5, 70, 3, 0, 0,
DIF_DROPDOWNLIST | DIF_LISTAUTOHIGHLIGHT | DIF_LISTNOAMPERSAND, 0, ""},
/* 7*/ {DI_TEXT, 3, 6, 0, 0, 0, 0, DIF_BOXCOLOR | DIF_SEPARATOR, 0, ""},
/* 8*/ {DI_TEXT, 5, 7, 0, 0, 0, 0, 0, 0, (char *)MAddPassword},
/* 9*/ {DI_PSWEDIT, 5, 8, 36, 8, 0, 0, 0, 0, ""},
/*10*/ {DI_TEXT, 39, 7, 0, 0, 0, 0, 0, 0, (char *)MAddReenterPassword},
/*11*/ {DI_PSWEDIT, 39, 8, 70, 8, 0, 0, 0, 0, ""},
/*12*/ {DI_TEXT, 3, 9, 0, 0, 0, 0, DIF_BOXCOLOR | DIF_SEPARATOR, 0, ""},
/*13*/ {DI_CHECKBOX, 5, 10, 0, 0, 0, 0, 0, 0, (char *)MAddDelete},
/*14*/ {DI_CHECKBOX, 5, 11, 0, 0, 0, 0, 0, 0, (char *)MExactArcName},
/*15*/ {DI_TEXT, 50, 10, 0, 0, 0, 0, 0, 0, (char *)MPriorityOfProcess},
/*16*/ {DI_COMBOBOX, 50, 11, 70, 11, 0, 0, DIF_DROPDOWNLIST, 0, ""},
/*17*/ {DI_CHECKBOX, 5, 12, 0, 0, 0, 0, 0, 0, (char *)MBackground},
/*18*/ {DI_TEXT, 3, 13, 0, 0, 0, 0, DIF_BOXCOLOR | DIF_SEPARATOR, 0, ""},
/*19*/ {DI_BUTTON, 0, 14, 0, 0, 0, 0, DIF_CENTERGROUP, 1, (char *)MAddAdd},
/*20*/ {DI_BUTTON, 0, 14, 0, 0, 0, 0, DIF_CENTERGROUP, 0, (char *)MAddSelect},
/*21*/ {DI_BUTTON, 0, 14, 0, 0, 0, 0, DIF_CENTERGROUP | DIF_DISABLE, 0, (char *)MAddSave},
/*22*/ {DI_BUTTON, 0, 14, 0, 0, 0, 0, DIF_CENTERGROUP, 0, (char *)MAddCancel},
};
struct FarDialogItem DialogItems[ARRAYSIZE(InitItems)] = {};
InitDialogItems(InitItems, DialogItems, ARRAYSIZE(InitItems));
/* if(OLD_DIALOG_STYLE)
{
DialogItems[PDI_SWITCHESCAPT].X1=5;
DialogItems[PDI_SWITCHESEDT].X1=5;
}*/
SelectFormatComboBox Box(&DialogItems[PDI_SELARCCOMB], pdd.ArcFormat);
// <Prior>
FarListItem ListPriorItem[5];
for (size_t I = 0; I < ARRAYSIZE(ListPriorItem); ++I) {
ListPriorItem[I].Flags = 0;
CharArrayCpyZ(ListPriorItem[I].Text, GetMsg((int)(MIdle_Priority_Class + I)));
}
ListPriorItem[Opt.PriorityClass].Flags = LIF_SELECTED;
FarList ListPrior;
ListPrior.ItemsNumber = ARRAYSIZE(ListPriorItem);
ListPrior.Items = &ListPriorItem[0];
DialogItems[PDI_PRIORCBOX].ListItems = &ListPrior;
// </Prior>
if (Opt.UseLastHistory)
DialogItems[PDI_SWITCHESEDT].Flags|= DIF_USELASTHISTORY;
if (!ArcName.empty()) {
pdd.NoChangeArcName = TRUE;
pdd.OldExactState = TRUE;
RestoreExactState = TRUE;
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, ArcName.c_str());
} else {
PanelInfo pi;
Info.Control(INVALID_HANDLE_VALUE, FCTL_GETPANELINFO, &pi);
#ifdef _ARC_UNDER_CURSOR_
std::string ArcName(DialogItems[PDI_ARCNAMEEDT].Data);
if (GetCursorName(ArcName, pdd.ArcFormat, pdd.DefExt, &pi)) {
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, ArcName.c_str());
// pdd.NoChangeArcName=TRUE;
RestoreExactState = TRUE;
pdd.OldExactState = TRUE;
} else {
#endif //_ARC_UNDER_CURSOR_
// pdd.OldExactState=Opt.AdvFlags.AutoResetExactArcName?FALSE:Opt.AdvFlags.ExactArcName;
pdd.OldExactState = OldExactState;
#ifdef _GROUP_NAME_
if (ItemsNumber == 1 && pi.SelectedItemsNumber == 1
&& (pi.SelectedItems[0].Flags & PPIF_SELECTED)) {
char CurDir[NM] = {0};
if (sdc_getcwd(CurDir, sizeof(CurDir)))
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, FSF.PointToName(CurDir));
} else {
const auto &group = GetGroupName(PanelItem, ItemsNumber);
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, group.c_str());
}
#else //_GROUP_NAME_
if (ItemsNumber == 1 && pi.SelectedItemsNumber == 1
&& !(pi.SelectedItems[0].Flags & PPIF_SELECTED)) {
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, PanelItem->FindData.cFileName);
char *Dot = strrchr(DialogItems[PDI_ARCNAMEEDT].Data, '.');
if (Dot != NULL)
*Dot = 0;
} else {
char CurDir[NM];
GetCurrentDirectory(sizeof(CurDir), CurDir);
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, FSF.PointToName(CurDir));
}
#endif // else _GROUP_NAME_
if (pdd.OldExactState && ArcName.empty()) {
std::string ArcNameTmp = DialogItems[PDI_ARCNAMEEDT].Data;
if (AddExt(ArcNameTmp, pdd.DefExt)) {
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, ArcNameTmp.c_str());
}
}
#ifdef _ARC_UNDER_CURSOR_
}
#endif //_ARC_UNDER_CURSOR_
/* $ AA 29.11.2001 //нафига нам имя усреднять?
char AnsiName[NM];
OemToAnsi(DialogItems[PDI_ARCNAMEEDT].Data,AnsiName);
if(!IsCaseMixed(AnsiName))
{
CharLower(AnsiName);
AnsiToOem(AnsiName, DialogItems[PDI_ARCNAMEEDT].Data);
}
AA 29.11.2001 $ */
}
DialogItems[PDI_ADDDELCHECK].Selected = Move;
/* $ 13.04.2001 DJ
UserBackground instead of Background
*/
DialogItems[PDI_BGROUNDCHECK].Selected = Opt.UserBackground;
/* DJ $ */
// strcpy(pdd.OriginalName,DialogItems[PDI_ARCNAMEEDT].Data);
if ((OpMode & OPM_SILENT) == 0) {
int AskCode = Info.DialogEx(Info.ModuleNumber, -1, -1, 76, 17, "AddToArc", DialogItems,
ARRAYSIZE(DialogItems), 0, 0, PluginClass::PutDlgProc, (LONG_PTR)&pdd);
pdd.Password1 = DialogItems[PDI_PASS0WEDT].Data;
// strcpy(pdd.Password2,DialogItems[PDI_PASS1WEDT].Data); //$ AA 28.11.2001
Opt.UserBackground = DialogItems[PDI_BGROUNDCHECK].Selected;
Opt.PriorityClass = DialogItems[PDI_PRIORCBOX].ListPos;
if (RestoreExactState)
Opt.AdvFlags.ExactArcName = OldExactState;
else
Opt.AdvFlags.ExactArcName = DialogItems[PDI_EXACTNAMECHECK].Selected;
// SetRegKey(HKEY_CURRENT_USER, "", "ExactArcName", Opt.ExactArcName);
{
KeyFileHelper(INI_LOCATION).SetInt(INI_SECTION, "AdvFlags", (int)Opt.AdvFlags);
}
FSF.Unquote(DialogItems[PDI_ARCNAMEEDT].Data);
if (AskCode != PDI_ADDBTN || *DialogItems[PDI_ARCNAMEEDT].Data == 0) {
Opt.PriorityClass = 2;
return -1;
}
// SetRegKey(HKEY_CURRENT_USER,"","Background",Opt.UserBackground); // $ 06.02.2002 AA
}
std::string Tmp = DialogItems[PDI_ARCNAMEEDT].Data;
if (DialogItems[PDI_EXACTNAMECHECK].Selected) {
size_t p = Tmp.find_last_of("/.");
if (p == std::string::npos || Tmp[p] != '.') {
Tmp+= '.';
}
} else
AddExt(Tmp, pdd.DefExt);
CharArrayCpyZ(DialogItems[PDI_ARCNAMEEDT].Data, Tmp.c_str());
int Recurse = FALSE;
for (int I = 0; I < ItemsNumber; I++)
if (PanelItem[I].FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
Recurse = TRUE;
break;
}
for (int I = 0; I < ItemsNumber; I++) //!! $ 22.03.2002 AA временный фикс !!
PanelItem[I].UserData = 0; // CHECK FOR BUGS!!!
int CommandType;
if (DialogItems[PDI_ADDDELCHECK].Selected)
CommandType = Recurse ? CMD_MOVERECURSE : CMD_MOVE;
else
CommandType = Recurse ? CMD_ADDRECURSE : CMD_ADD;
Opt.Background = OpMode & OPM_SILENT ? 0 : Opt.UserBackground;
{
KeyFileReadSection kfh(INI_LOCATION, pdd.ArcFormat);
ArcPlugin->GetDefaultCommands(ArcPluginNumber, ArcPluginType, CommandType, Command);
Command = kfh.GetString(CmdNames[CommandType], Command.c_str());
ArcPlugin->GetDefaultCommands(ArcPluginNumber, ArcPluginType, CMD_ALLFILESMASK, AllFilesMask);
AllFilesMask = kfh.GetString("AllFilesMask", AllFilesMask.c_str());
}
if (*CurDir && Command.find("%%R") == std::string::npos && Command.find("%%r") == std::string::npos) {
const char *MsgItems[] = {GetMsg(MWarning), GetMsg(MCannotPutToFolder), GetMsg(MPutToRoot),
GetMsg(MOk), GetMsg(MCancel)};
if (Info.Message(Info.ModuleNumber, 0, NULL, MsgItems, ARRAYSIZE(MsgItems), 2) != 0) {
Opt.PriorityClass = 2;
return -1;
} else
*CurDir = 0;
}
size_t SwPos = Command.find("%%S");
if (SwPos != std::string::npos) {
if (SwPos > 0 && SwPos + 3 < Command.size() && Command[SwPos - 1] == '{'
&& Command[SwPos + 3] == '}')
Command.replace(SwPos - 1, 5, DialogItems[PDI_SWITCHESEDT].Data);
else
Command.replace(SwPos, 3, DialogItems[PDI_SWITCHESEDT].Data);
} else if (*DialogItems[PDI_SWITCHESEDT].Data) {
SwPos = Command.find(" -- ");
if (SwPos == std::string::npos)
SwPos = Command.size();
Command.insert(SwPos, DialogItems[PDI_SWITCHESEDT].Data);
Command.insert(SwPos, " ");
}
int IgnoreErrors = (CurArcInfo.Flags & AF_IGNOREERRORS);
FSF.Unquote(DialogItems[PDI_ARCNAMEEDT].Data);
NewArchive = !FileExists(DialogItems[PDI_ARCNAMEEDT].Data);
ArcCommand ArcCmd(PanelItem, ItemsNumber, Command.c_str(), DialogItems[PDI_ARCNAMEEDT].Data, "",
pdd.Password1, AllFilesMask.c_str(), IgnoreErrors, CommandType, 0, CurDir, ItemsInfo.Codepage);
// последующие операции (тестирование и тд) не должны быть фоновыми
Opt.Background = 0; // $ 06.02.2002 AA
if (!IgnoreErrors && ArcCmd.GetExecCode() != 0)
ArcExitCode = 0;
if (ArcCmd.GetExecCode() == RETEXEC_ARCNOTFOUND)
continue;
std::string fullname = MakeFullName(DialogItems[PDI_ARCNAMEEDT].Data);
if (!fullname.empty())
ArcName = std::move(fullname);
break;
}
Opt.PriorityClass = 2;
if (Opt.UpdateDescriptions && ArcExitCode)
for (int I = 0; I < ItemsNumber; I++)
PanelItem[I].Flags|= PPIF_PROCESSDESCR;
if (!Opt.UserBackground && ArcExitCode && NewArchive && GoToFile(ArcName.c_str(), Opt.AllowChangeDir))
ArcExitCode = 2;
return ArcExitCode;
}

@exkrexpexfex
Copy link
Contributor

exkrexpexfex commented Oct 13, 2024

@akruphi @Zeroes1 В диалоге создания архива есть галочка Exact archive filename, которая отключает добавление расширения. Если не выбрана, то расширение добавляется путем замены текста за последней точкой в имени архива. Наверно правильным решением будет

  • Сразу добавлять расширение в предлагаемое имя архива при открытии диалога или при смене типа архиватора
  • При этом не заменять текст за последней точкой, а добавлять в конец, если архивируем папку или когда выбрано несколько файлов и подставляется имя родительской папки, иначе заменять
  • Убрать непонятную галочку Exact archive filename и всегда использовать полный текст из строчки в диалоге в качестве целевого имени архива, без сюрпризов для пользователя

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants