UPD: SevenZip - prepare Unix support

This commit is contained in:
Alexander Koblov 2024-11-10 13:33:05 +03:00
commit 9066702bc4

View file

@ -149,7 +149,7 @@ type
// "23170F69-40C1-278A-0000-000300xx0000"
ISequentialInStream = interface(IUnknown)
['{23170F69-40C1-278A-0000-000300010000}']
function Read(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; stdcall;
function Read(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; winapi;
{Out: if size != 0, return_value = S_OK and (*processedSize == 0),
then there are no more bytes in stream.
if (size > 0) && there are bytes in stream,
@ -160,7 +160,7 @@ type
ISequentialOutStream = interface(IUnknown)
['{23170F69-40C1-278A-0000-000300020000}']
function Write(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; stdcall;
function Write(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; winapi;
{if (size > 0) this function must write at least 1 byte.
This function is allowed to write less than "size".
You must call Write function in loop, if you need to write exact amount of data}
@ -168,23 +168,23 @@ type
IInStream = interface(ISequentialInStream)
['{23170F69-40C1-278A-0000-000300030000}']
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; stdcall;
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; winapi;
end;
IOutStream = interface(ISequentialOutStream)
['{23170F69-40C1-278A-0000-000300040000}']
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; stdcall;
function SetSize(NewSize: Int64): HRESULT; stdcall;
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; winapi;
function SetSize(NewSize: Int64): HRESULT; winapi;
end;
IStreamGetSize = interface(IUnknown)
['{23170F69-40C1-278A-0000-000300060000}']
function GetSize(Size: PInt64): HRESULT; stdcall;
function GetSize(Size: PInt64): HRESULT; winapi;
end;
IOutStreamFlush = interface(IUnknown)
['{23170F69-40C1-278A-0000-000300070000}']
function Flush: HRESULT; stdcall;
function Flush: HRESULT; winapi;
end;
// PropID.h
@ -282,13 +282,13 @@ const
type
ICompressProgressInfo = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400040000}']
function SetRatioInfo(InSize: PInt64; OutSize: PInt64): HRESULT; stdcall;
function SetRatioInfo(InSize: PInt64; OutSize: PInt64): HRESULT; winapi;
end;
ICompressCoder = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400050000}']
function Code(InStream: ISequentialInStream; OutStream: ISequentialOutStream;
InSize, OutSize: PInt64; Progress: ICompressProgressInfo): HRESULT; stdcall;
InSize, OutSize: PInt64; Progress: ICompressProgressInfo): HRESULT; winapi;
end;
PISequentialInStream = ^ISequentialInStream;
@ -298,7 +298,7 @@ type
['{23170F69-40C1-278A-0000-000400180000}']
function Code(InStreams: PISequentialInStream; InSizes: JclBase.PPInt64; NumInStreams: Cardinal;
OutStreams: PISequentialOutStream; OutSizes: JclBase.PPInt64; NumOutStreams: Cardinal;
Progress: ICompressProgressInfo): HRESULT; stdcall;
Progress: ICompressProgressInfo): HRESULT; winapi;
end;
const
@ -322,60 +322,60 @@ type
ICompressSetCoderProperties = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400200000}']
function SetCoderProperties(PropIDs: PPropID; Properties: PPropVariant;
NumProperties: Cardinal): HRESULT; stdcall;
NumProperties: Cardinal): HRESULT; winapi;
end;
ICompressSetDecoderProperties2 = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400220000}']
function SetDecoderProperties2(Data: PByte; Size: Cardinal): HRESULT; stdcall;
function SetDecoderProperties2(Data: PByte; Size: Cardinal): HRESULT; winapi;
end;
ICompressWriteCoderProperties = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400230000}']
function WriteCoderProperties(OutStream: ISequentialOutStream): HRESULT; stdcall;
function WriteCoderProperties(OutStream: ISequentialOutStream): HRESULT; winapi;
end;
ICompressGetInStreamProcessedSize = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400240000}']
function GetInStreamProcessedSize(Value: PInt64): HRESULT; stdcall;
function GetInStreamProcessedSize(Value: PInt64): HRESULT; winapi;
end;
ICompressSetCoderMt = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400250000}']
function SetNumberOfThreads(NumThreads: Cardinal): HRESULT; stdcall;
function SetNumberOfThreads(NumThreads: Cardinal): HRESULT; winapi;
end;
ICompressGetSubStreamSize = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400300000}']
function GetSubStreamSize(SubStream: Int64; out Value: Int64): HRESULT; stdcall;
function GetSubStreamSize(SubStream: Int64; out Value: Int64): HRESULT; winapi;
end;
ICompressSetInStream = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400310000}']
function SetInStream(InStream: ISequentialInStream): HRESULT; stdcall;
function ReleaseInStream: HRESULT; stdcall;
function SetInStream(InStream: ISequentialInStream): HRESULT; winapi;
function ReleaseInStream: HRESULT; winapi;
end;
ICompressSetOutStream = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400320000}']
function SetOutStream(OutStream: ISequentialOutStream): HRESULT; stdcall;
function ReleaseOutStream: HRESULT; stdcall;
function SetOutStream(OutStream: ISequentialOutStream): HRESULT; winapi;
function ReleaseOutStream: HRESULT; winapi;
end;
ICompressSetInStreamSize = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400330000}']
function SetInStreamSize(InSize: PInt64): HRESULT; stdcall;
function SetInStreamSize(InSize: PInt64): HRESULT; winapi;
end;
ICompressSetOutStreamSize = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400340000}']
function SetOutStreamSize(OutSize: PInt64): HRESULT; stdcall;
function SetOutStreamSize(OutSize: PInt64): HRESULT; winapi;
end;
ICompressFilter = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400400000}']
function Init: HRESULT; stdcall;
function Filter(Data: PByte; Size: Cardinal): Cardinal; stdcall;
function Init: HRESULT; winapi;
function Filter(Data: PByte; Size: Cardinal): Cardinal; winapi;
// Filter return outSize (UInt32)
// if (outSize <= size): Filter have converted outSize bytes
// if (outSize > size): Filter have not converted anything.
@ -385,31 +385,31 @@ type
ICompressCodecsInfo = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400600000}']
function GetNumberOfMethods(NumMethods: PCardinal): HRESULT; stdcall;
function GetProperty(Index: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function CreateDecoder(Index: Cardinal; IID: PGUID; out Decoder): HRESULT; stdcall;
function CreateEncoder(Index: Cardinal; IID: PGUID; out Coder): HRESULT; stdcall;
function GetNumberOfMethods(NumMethods: PCardinal): HRESULT; winapi;
function GetProperty(Index: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function CreateDecoder(Index: Cardinal; IID: PGUID; out Decoder): HRESULT; winapi;
function CreateEncoder(Index: Cardinal; IID: PGUID; out Coder): HRESULT; winapi;
end;
ISetCompressCodecsInfo = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400610000}']
function SetCompressCodecsInfo(CompressCodecsInfo: ICompressCodecsInfo): HRESULT; stdcall;
function SetCompressCodecsInfo(CompressCodecsInfo: ICompressCodecsInfo): HRESULT; winapi;
end;
ICryptoProperties = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400800000}']
function SetKey(Data: PByte; Size: Cardinal): HRESULT; stdcall;
function SetInitVector(Data: PByte; Size: Cardinal): HRESULT; stdcall;
function SetKey(Data: PByte; Size: Cardinal): HRESULT; winapi;
function SetInitVector(Data: PByte; Size: Cardinal): HRESULT; winapi;
end;
ICryptoSetPassword = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400900000}']
function CryptoSetPassword(Data: PByte; Size: Cardinal): HRESULT; stdcall;
function CryptoSetPassword(Data: PByte; Size: Cardinal): HRESULT; winapi;
end;
ICryptoSetCRC = interface(IUnknown)
['{23170F69-40C1-278A-0000-000400A00000}']
function CryptoSetCRC(crc: Cardinal): HRESULT; stdcall;
function CryptoSetCRC(crc: Cardinal): HRESULT; winapi;
end;
const
@ -427,8 +427,8 @@ const
type
IProgress = interface(IUnknown)
['{23170F69-40C1-278A-0000-000000050000}']
function SetTotal(Total: Int64): HRESULT; stdcall;
function SetCompleted(CompleteValue: PInt64): HRESULT; stdcall;
function SetTotal(Total: Int64): HRESULT; winapi;
function SetCompleted(CompleteValue: PInt64): HRESULT; winapi;
end;
// IArchive.h
@ -466,57 +466,57 @@ type
// "23170F69-40C1-278A-0000-000600xx0000"
IArchiveOpenCallback = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600100000}']
function SetTotal(Files: PInt64; Bytes: PInt64): HRESULT; stdcall;
function SetCompleted(Files: PInt64; Bytes: PInt64): HRESULT; stdcall;
function SetTotal(Files: PInt64; Bytes: PInt64): HRESULT; winapi;
function SetCompleted(Files: PInt64; Bytes: PInt64): HRESULT; winapi;
end;
IArchiveExtractCallback = interface(IProgress)
['{23170F69-40C1-278A-0000-000600200000}']
function GetStream(Index: Cardinal; out OutStream: ISequentialOutStream;
askExtractMode: Cardinal): HRESULT; stdcall;
askExtractMode: Cardinal): HRESULT; winapi;
// GetStream OUT: S_OK - OK, S_FALSE - skeep this file
function PrepareOperation(askExtractMode: Cardinal): HRESULT; stdcall;
function SetOperationResult(resultEOperationResult: Integer): HRESULT; stdcall;
function PrepareOperation(askExtractMode: Cardinal): HRESULT; winapi;
function SetOperationResult(resultEOperationResult: Integer): HRESULT; winapi;
end;
IArchiveOpenVolumeCallback = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600300000}']
function GetProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetStream(Name: PWideChar; out InStream: IInStream): HRESULT; stdcall;
function GetProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetStream(Name: PWideChar; out InStream: IInStream): HRESULT; winapi;
end;
IInArchiveGetStream = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600400000}']
function GetStream(Index: Cardinal; out Stream: ISequentialInStream): HRESULT; stdcall;
function GetStream(Index: Cardinal; out Stream: ISequentialInStream): HRESULT; winapi;
end;
IArchiveOpenSetSubArchiveName = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600500000}']
function SetSubArchiveName(Name: PWideChar): HRESULT; stdcall;
function SetSubArchiveName(Name: PWideChar): HRESULT; winapi;
end;
IInArchive = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600600000}']
function Open(Stream: IInStream; MaxCheckStartPosition: PInt64;
OpenArchiveCallback: IArchiveOpenCallback): HRESULT; stdcall;
function Close: HRESULT; stdcall;
function GetNumberOfItems(NumItems: PCardinal): HRESULT; stdcall;
OpenArchiveCallback: IArchiveOpenCallback): HRESULT; winapi;
function Close: HRESULT; winapi;
function GetNumberOfItems(NumItems: PCardinal): HRESULT; winapi;
function GetProperty(Index: Cardinal; PropID: TPropID;
var Value: TPropVariant): HRESULT; stdcall;
var Value: TPropVariant): HRESULT; winapi;
function Extract(Indices: PCardinal; NumItems: Cardinal;
TestMode: Integer; ExtractCallback: IArchiveExtractCallback): HRESULT; stdcall;
TestMode: Integer; ExtractCallback: IArchiveExtractCallback): HRESULT; winapi;
// indices must be sorted
// numItems = 0xFFFFFFFF means all files
// testMode != 0 means "test files operation"
function GetArchiveProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetArchiveProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetNumberOfProperties(NumProperties: PCardinal): HRESULT; stdcall;
function GetNumberOfProperties(NumProperties: PCardinal): HRESULT; winapi;
function GetPropertyInfo(Index: Cardinal; out Name: TBStr; out PropID: TPropID;
out VarType: TVarType): HRESULT; stdcall;
out VarType: TVarType): HRESULT; winapi;
function GetNumberOfArchiveProperties(NumProperties: PCardinal): HRESULT; stdcall;
function GetNumberOfArchiveProperties(NumProperties: PCardinal): HRESULT; winapi;
function GetArchivePropertyInfo(Index: Cardinal; out Name: TBStr; out PropID: TPropID;
out VarType: TVarType): HRESULT; stdcall;
out VarType: TVarType): HRESULT; winapi;
end;
IArchiveUpdateCallback = interface(IProgress)
@ -525,41 +525,41 @@ type
NewData: PInteger; // 1 - new data, 0 - old data
NewProperties: PInteger; // 1 - new properties, 0 - old properties
IndexInArchive: PCardinal // -1 if there is no in archive, or if doesn't matter
): HRESULT; stdcall;
function GetProperty(Index: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetStream(Index: Cardinal; out InStream: ISequentialInStream): HRESULT; stdcall;
function SetOperationResult(OperationResult: Integer): HRESULT; stdcall;
): HRESULT; winapi;
function GetProperty(Index: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetStream(Index: Cardinal; out InStream: ISequentialInStream): HRESULT; winapi;
function SetOperationResult(OperationResult: Integer): HRESULT; winapi;
end;
IArchiveUpdateCallback2 = interface(IArchiveUpdateCallback)
['{23170F69-40C1-278A-0000-000600820000}']
function GetVolumeSize(Index: Cardinal; Size: PInt64): HRESULT; stdcall;
function GetVolumeStream(Index: Cardinal; out VolumeStream: ISequentialOutStream): HRESULT; stdcall;
function GetVolumeSize(Index: Cardinal; Size: PInt64): HRESULT; winapi;
function GetVolumeStream(Index: Cardinal; out VolumeStream: ISequentialOutStream): HRESULT; winapi;
end;
IOutArchive = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600A00000}']
function UpdateItems(OutStream: ISequentialOutStream; NumItems: Cardinal;
UpdateCallback: IArchiveUpdateCallback): HRESULT; stdcall;
function GetFileTimeType(Type_: PCardinal): HRESULT; stdcall;
UpdateCallback: IArchiveUpdateCallback): HRESULT; winapi;
function GetFileTimeType(Type_: PCardinal): HRESULT; winapi;
end;
ISetProperties = interface(IUnknown)
['{23170F69-40C1-278A-0000-000600030000}']
function SetProperties(Names: PPWideChar; Values: PPropVariant; NumProperties: Integer): HRESULT; stdcall;
function SetProperties(Names: PPWideChar; Values: PPropVariant; NumProperties: Integer): HRESULT; winapi;
end;
// IPassword.h
type
ICryptoGetTextPassword = interface(IUnknown)
['{23170F69-40C1-278A-0000-000500100000}']
function CryptoGetTextPassword(password: PBStr): HRESULT; stdcall;
function CryptoGetTextPassword(password: PBStr): HRESULT; winapi;
end;
ICryptoGetTextPassword2 = interface(IUnknown)
['{23170F69-40C1-278A-0000-000500110000}']
function CryptoGetTextPassword2(PasswordIsDefined: PInteger;
Password: PBStr): HRESULT; stdcall;
Password: PBStr): HRESULT; winapi;
end;
// ZipHandlerOut.cpp
@ -621,13 +621,13 @@ const
{$IFDEF 7ZIP_LINKONREQUEST}
type
TCreateObjectFunc = function (ClsID: PGUID; IID: PGUID; out Obj): HRESULT; stdcall;
TGetHandlerProperty2 = function (FormatIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
TGetHandlerProperty = function (PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
TGetMethodProperty = function (CodecIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
TGetNumberOfFormatsFunc = function (NumFormats: PCardinal): HRESULT; stdcall;
TGetNumberOfMethodsFunc = function (NumMethods: PCardinal): HRESULT; stdcall;
TSetLargePageMode = function: HRESULT; stdcall;
TCreateObjectFunc = function (ClsID: PGUID; IID: PGUID; out Obj): HRESULT; winapi;
TGetHandlerProperty2 = function (FormatIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
TGetHandlerProperty = function (PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
TGetMethodProperty = function (CodecIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
TGetNumberOfFormatsFunc = function (NumFormats: PCardinal): HRESULT; winapi;
TGetNumberOfMethodsFunc = function (NumMethods: PCardinal): HRESULT; winapi;
TSetLargePageMode = function: HRESULT; winapi;
var
CreateObject: TCreateObjectFunc = nil;
@ -637,20 +637,27 @@ var
GetNumberOfFormats: TGetNumberOfFormatsFunc = nil;
GetNumberOfMethods: TGetNumberOfMethodsFunc = nil;
SetLargePageMode: TSetLargePageMode = nil;
{$IF DEFINED(UNIX)}
SysAllocString: function(psz: pointer): TBStr; winapi;
SysFreeString: procedure(bstr:pointer); winapi;
SysStringByteLen: function(bstr:pointer): UINT; winapi;
{$ENDIF}
{$ELSE ~7ZIP_LINKONREQUEST}
function CreateObject(ClsID: PGUID; IID: PGUID; out Obj): HRESULT; stdcall;
function GetHandlerProperty2(FormatIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetHandlerProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetMethodProperty(CodecIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; stdcall;
function GetNumberOfFormats(NumFormats: PCardinal): HRESULT; stdcall;
function GetNumberOfMethods(NumMethods: PCardinal): HRESULT; stdcall;
function SetLargePageMode: HRESULT; stdcall;
function CreateObject(ClsID: PGUID; IID: PGUID; out Obj): HRESULT; winapi;
function GetHandlerProperty2(FormatIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetHandlerProperty(PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetMethodProperty(CodecIndex: Cardinal; PropID: TPropID; out Value: TPropVariant): HRESULT; winapi;
function GetNumberOfFormats(NumFormats: PCardinal): HRESULT; winapi;
function GetNumberOfMethods(NumMethods: PCardinal): HRESULT; winapi;
function SetLargePageMode: HRESULT; winapi;
{$ENDIF ~7ZIP_LINKONREQUEST}
//DOM-IGNORE-END
const
SevenzipDefaultLibraryName = '7z.dll';
SevenzipDefaultLibraryName = '7z.' + SharedSuffix;
CreateObjectDefaultExportName = 'CreateObject';
GetHandlerProperty2DefaultExportName = 'GetHandlerProperty2';
GetHandlerPropertyDefaultExportName = 'GetHandlerProperty';
@ -717,6 +724,13 @@ begin
@GetNumberOfFormats := GetModuleSymbol(SevenzipLibraryHandle, GetNumberOfFormatsExportName);
@GetNumberOfMethods := GetModuleSymbol(SevenzipLibraryHandle, GetNumberOfMethodsExportName);
@SetLargePageMode := GetModuleSymbol(SevenzipLibraryHandle, SetLargePageModeExportName);
{$IF DEFINED(UNIX)}
@SysAllocString:= GetProcAddress(SevenzipLibraryHandle, 'SysAllocString');
@SysFreeString:= GetProcAddress(SevenzipLibraryHandle, 'SysFreeString');
@SysStringByteLen:= GetProcAddress(SevenzipLibraryHandle, 'SysStringByteLen');
{$ENDIF}
Result := Assigned(@CreateObject) and Assigned(@GetHandlerProperty2) and
Assigned(@GetHandlerProperty) and Assigned(@GetMethodProperty) and
Assigned(@GetNumberOfFormats) and Assigned(@GetNumberOfMethods) and