mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Unrar 7 support
This commit is contained in:
parent
8dee95cc1b
commit
3b7ddb2524
3 changed files with 97 additions and 5 deletions
67
plugins/wcx/unrar/src/rarlng.pas
Normal file
67
plugins/wcx/unrar/src/rarlng.pas
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
Double Commander
|
||||
-------------------------------------------------------------------------
|
||||
Rar archiver plugin, language support
|
||||
|
||||
Copyright (C) 2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
}
|
||||
|
||||
unit RarLng;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
resourcestring
|
||||
rsMsgButtonCancel = '&Cancel';
|
||||
rsMsgButtonExtract = '&Extract';
|
||||
rsDictLargeWarning = 'Large dictionary warning';
|
||||
rsDictNotAllowed = '%u GB dictionary exceeds %u GB limit and needs more than %u GB memory to unpack.';
|
||||
rsMsgLibraryNotFound = 'Cannot load library %s! Please check your installation.';
|
||||
|
||||
procedure TranslateResourceStrings;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
UnRARFunc;
|
||||
|
||||
function Translate(Name, Value: AnsiString; Hash: LongInt; Arg: Pointer): AnsiString;
|
||||
var
|
||||
ALen: Integer;
|
||||
begin
|
||||
with gStartupInfo do
|
||||
begin
|
||||
SetLength(Result, MaxSmallint);
|
||||
ALen:= TranslateString(Translation, PAnsiChar(Name), PAnsiChar(Value), PAnsiChar(Result), MaxSmallint);
|
||||
SetLength(Result, ALen);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TranslateResourceStrings;
|
||||
begin
|
||||
if Assigned(gStartupInfo.Translation) then
|
||||
begin
|
||||
SetResourceStrings(@Translate, nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ uses
|
|||
{$IFDEF UNIX}
|
||||
cthreads,
|
||||
{$ENDIF}
|
||||
FPCAdds, SysUtils, DynLibs, UnRARFunc, RarFunc;
|
||||
FPCAdds, SysUtils, DynLibs, UnRARFunc, RarFunc, RarLng;
|
||||
|
||||
exports
|
||||
{ Mandatory }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
WCX plugin for unpacking RAR archives
|
||||
This is simple wrapper for unrar.dll or libunrar.so
|
||||
|
||||
Copyright (C) 2008-2022 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2008-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
|
|
@ -54,6 +54,7 @@ const
|
|||
UCM_NEEDPASSWORD = 2;
|
||||
UCM_CHANGEVOLUMEW = 3;
|
||||
UCM_NEEDPASSWORDW = 4;
|
||||
UCM_LARGEDICT = 5;
|
||||
|
||||
// Main header flags.
|
||||
MHD_VOLUME = $0001;
|
||||
|
|
@ -173,7 +174,8 @@ threadvar
|
|||
implementation
|
||||
|
||||
uses
|
||||
SysUtils, DCBasicTypes, DCDateTimeUtils, DCConvertEncoding, DCFileAttributes;
|
||||
SysUtils, DCBasicTypes, DCDateTimeUtils, DCConvertEncoding, DCFileAttributes,
|
||||
RarLng;
|
||||
|
||||
type
|
||||
// From libunrar (dll.hpp)
|
||||
|
|
@ -268,8 +270,12 @@ begin
|
|||
end;
|
||||
|
||||
function UnrarCallback(Msg: LongWord; UserData, P1: Pointer; P2: PtrInt) : Integer; dcpcall;
|
||||
const
|
||||
Giga = 1024 * 1024;
|
||||
var
|
||||
PasswordU: String;
|
||||
Buttons: PPAnsiChar;
|
||||
DictSize: UIntPtr absolute P1;
|
||||
VolumeNameA: TRarUnicodeArray;
|
||||
VolumeNameU: TRarUnicodeString;
|
||||
PasswordA: array[0..511] of AnsiChar;
|
||||
|
|
@ -329,6 +335,23 @@ begin
|
|||
StrLCopy(PRarUnicodeChar(P1), PRarUnicodeChar(WideStringToRarUnicodeString(VolumeNameW)), P2 - 1);
|
||||
end;
|
||||
end;
|
||||
UCM_LARGEDICT:
|
||||
begin
|
||||
P2:= P2 div Giga;
|
||||
DictSize:= (DictSize div Giga) + Ord((DictSize mod Giga <> 0));
|
||||
Buttons:= ArrayStringToPPchar([rsMsgButtonExtract, rsMsgButtonCancel], 0);
|
||||
try
|
||||
PasswordU:= Format(rsDictNotAllowed, [DictSize, P2, DictSize]) + LineEnding;
|
||||
|
||||
if gStartupInfo.MsgChoiceBox(PAnsiChar(PasswordU), PAnsiChar(rsDictLargeWarning), Buttons) = 0 then
|
||||
Result:= 1
|
||||
else begin
|
||||
Result:= -1;
|
||||
end;
|
||||
finally
|
||||
FreeMem(Buttons);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
@ -513,10 +536,12 @@ end;
|
|||
procedure ExtensionInitialize(StartupInfo: PExtensionStartupInfo); dcpcall;
|
||||
begin
|
||||
gStartupInfo := StartupInfo^;
|
||||
TranslateResourceStrings;
|
||||
|
||||
if ModuleHandle = NilHandle then
|
||||
begin
|
||||
gStartupInfo.MessageBox('Cannot load library ' + _unrar + '! Please check your installation.',
|
||||
nil, MB_OK or MB_ICONERROR);
|
||||
gStartupInfo.MessageBox(PAnsiChar(Format(rsMsgLibraryNotFound, [_unrar])),
|
||||
nil, MB_OK or MB_ICONERROR);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue