20230131
This commit is contained in:
parent
581bc98f75
commit
703d2d5a52
103
jarunpacker.lpi
Normal file
103
jarunpacker.lpi
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="jarunpacker"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<UseVersionInfo Value="True"/>
|
||||
<AutoIncrementBuild Value="True"/>
|
||||
<MajorVersionNr Value="2023"/>
|
||||
<MinorVersionNr Value="1"/>
|
||||
<RevisionNr Value="31"/>
|
||||
<Language Value="0419"/>
|
||||
<StringTable Comments="fwZIP создан Rouse_" CompanyName="Александр Бабаев" FileDescription="JAR UnPacker ZIP Tool" InternalName="jarunpacker" LegalCopyright="Александр Бабаев" LegalTrademarks="Александр Бабаев" OriginalFilename="jarunpacker" ProductName="Jar Unpacker" ProductVersion="2023.01.31"/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Win32" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="ANBSTCP"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="fwzip"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="jarunpacker.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value=".\output\jarunpacker"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="data\lib"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<TargetCPU Value="i386"/>
|
||||
<TargetOS Value="win32"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
<SmallerCode Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf3"/>
|
||||
<StripSymbols Value="True"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
162
jarunpacker.lpr
Normal file
162
jarunpacker.lpr
Normal file
@ -0,0 +1,162 @@
|
||||
program jarunpacker;
|
||||
|
||||
{$mode delphi}
|
||||
{$codepage UTF8}
|
||||
uses
|
||||
Interfaces,
|
||||
Classes,
|
||||
Windows,
|
||||
FWZipReader,
|
||||
SysUtils,
|
||||
ParamsMngr,
|
||||
LazUTF8Classes,
|
||||
FWZipConsts,
|
||||
FWZipWriter,
|
||||
FWZipZLib,
|
||||
SimplyJSON,
|
||||
LazFileUtils,
|
||||
ANBFormatString;
|
||||
|
||||
{$R *.res}
|
||||
resourcestring
|
||||
msg_consoletitle = 'JAR Unpacker Tool';
|
||||
msg_noparametrsfound = #13#10 + '[ОШИБКА] Параметры не заданы!';
|
||||
msg_extractingfile = 'Извлекаю файл: %s';
|
||||
msg_buildingfile = 'Сжимаю файл: %s';
|
||||
|
||||
procedure ExtractJAR(const JARName, TargetDir, ListFileName: string);
|
||||
var
|
||||
Reader: TFWZipReader;
|
||||
zItem: TFWZipReaderItem;
|
||||
FS: TFileStreamUTF8;
|
||||
FL: TStringList;
|
||||
Indx: integer;
|
||||
begin
|
||||
FS := TFileStreamUTF8.Create(JARName, fmOpenRead + fmShareExclusive);
|
||||
FL := TStringList.Create;
|
||||
Reader := TFWZipReader.Create;
|
||||
try
|
||||
Reader.LoadFromStream(FS);
|
||||
for Indx := 0 to Reader.Count - 1 do
|
||||
begin
|
||||
zItem := Reader.Item[Indx];
|
||||
FL.Add(FormatStr(zItem.FileName + '=' + zItem.FileName, ['/'], ['\']));
|
||||
end;
|
||||
Reader.ExtractAll(TargetDir);
|
||||
finally
|
||||
Reader.Free;
|
||||
if Trim(ListFileName) <> '' then
|
||||
FL.SaveToFile(ListFileName);
|
||||
FreeAndNil(FL);
|
||||
FS.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CompressJAR(const JARName, SourceDir, ListFileName: string);
|
||||
var
|
||||
Writer: TFWZipWriter;
|
||||
FS: TFileStreamUTF8;
|
||||
FL: TStringList;
|
||||
begin
|
||||
if FileExistsUTF8(JARName) then
|
||||
DeleteFileUTF8(JARName);
|
||||
FS := TFileStreamUTF8.Create(JARName, fmCreate);
|
||||
FL := TStringList.Create;
|
||||
FL.LoadFromFile(ListFileName);
|
||||
SetCurrentDir(SourceDir);
|
||||
Writer := TFWZipWriter.Create(clMax);
|
||||
try
|
||||
Writer.AddFilesAndFolders(FL, True);
|
||||
Writer.BuildZip(FS);
|
||||
finally
|
||||
Writer.Free;
|
||||
FreeAndNil(FL);
|
||||
FS.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure WriteHelpExtract();
|
||||
begin
|
||||
WriteLn('Допустимые параметры команды extract:');
|
||||
WriteLn(' target - папка извлечения;');
|
||||
WriteLn(' listFile - имя файла для списка распакованных файлов.');
|
||||
WriteLn('');
|
||||
WriteLn('Пример:');
|
||||
WriteLn('/extract="d:\file.jar" /target="d:\toextract\" /listFile="d:\1.txt"');
|
||||
end;
|
||||
|
||||
procedure WriteHelpCompress();
|
||||
begin
|
||||
WriteLn('Допустимые параметры команды compress:');
|
||||
WriteLn(' from - папка с файлами для архива;');
|
||||
WriteLn(' filesList - имя файла со списком файлов для упаковки.');
|
||||
WriteLn('');
|
||||
WriteLn('Пример:');
|
||||
WriteLn('/compress="d:\file.jar" /from="d:\toextract\" /filesList="d:\1.txt"');
|
||||
end;
|
||||
|
||||
procedure WriteHelp();
|
||||
begin
|
||||
WriteLn('Допустимые параметры:');
|
||||
WriteLn(' extract - извлечение jar-архива;');
|
||||
WriteLn(' compres - сжатие jar-ахива.');
|
||||
WriteLn('');
|
||||
WriteHelpExtract;
|
||||
WriteLn('');
|
||||
WriteHelpCompress();
|
||||
WriteLn(msg_noparametrsfound);
|
||||
end;
|
||||
|
||||
var
|
||||
isHandled: boolean;
|
||||
JARName, TargetDir, ListFileName: string;
|
||||
begin
|
||||
SetConsoleTitle(PChar(msg_consoletitle));
|
||||
WriteLn('--------------------------------------------------------------------');
|
||||
WriteLn('****************Утилита упаковки/распаковки JAR файлов**************');
|
||||
WriteLn('*************************Версия: 2023.01.31*************************');
|
||||
WriteLn('**********Авторские права (c) 2016 - 2023, Александр Бабаев*********');
|
||||
WriteLn('--------------------------------------------------------------------');
|
||||
isHandled := False;
|
||||
if HasParam('extract') then
|
||||
begin
|
||||
if not (HasParam('target') and HasParam('listFile')) then
|
||||
begin
|
||||
WriteHelpExtract();
|
||||
ReadLn;
|
||||
isHandled := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
JARName := GetParamValue('extract');
|
||||
TargetDir := IncludeTrailingBackslash(GetParamValue('target'));
|
||||
ListFileName := GetParamValue('listFile');
|
||||
ExtractJAR(JARName, TargetDir, ListFileName);
|
||||
WriteLn(Format(msg_extractingfile, [JARName]));
|
||||
isHandled := True;
|
||||
end;
|
||||
end;
|
||||
if HasParam('compress') then
|
||||
begin
|
||||
if not (HasParam('from') and HasParam('filesList')) then
|
||||
begin
|
||||
WriteHelpExtract();
|
||||
ReadLn;
|
||||
isHandled := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
JARName := GetParamValue('compress');
|
||||
TargetDir := GetParamValue('from');
|
||||
ListFileName := GetParamValue('filesList');
|
||||
CompressJAR(JARName, TargetDir, ListFileName);
|
||||
WriteLn(Format(msg_buildingfile, [JARName]));
|
||||
isHandled := True;
|
||||
end;
|
||||
end;
|
||||
if not isHandled then
|
||||
begin
|
||||
WriteHelp();
|
||||
ReadLn;
|
||||
end;
|
||||
end.
|
Loading…
x
Reference in New Issue
Block a user