mirror of
https://github.com/ModOrganizer2/libbsarch.git
synced 2026-07-27 14:06:31 -07:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c535689ef4 | ||
|
|
3219ade30e | ||
|
|
4a88aab247 |
+5
-5
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5..3.15)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
option(copy_dll_to_binary_dir "Will copy libbsarch DLL to the binary directory. May not work if libbsarch is used as a subproject" ON)
|
||||
|
||||
@@ -40,7 +40,7 @@ add_custom_command(TARGET libbsarch POST_BUILD
|
||||
# libbsarch_OOP #
|
||||
############################################################
|
||||
|
||||
find_package(Qt5 OPTIONAL_COMPONENTS Core)
|
||||
find_package(Qt6 COMPONENTS Core REQUIRED)
|
||||
|
||||
add_library(libbsarch_OOP STATIC
|
||||
src/base_types.hpp
|
||||
@@ -95,9 +95,9 @@ if(copy_dll_to_binary_dir)
|
||||
endif()
|
||||
|
||||
#Adding Qt support
|
||||
if(Qt5_FOUND)
|
||||
message("libbsarch: Qt5 found, enabling Qt support")
|
||||
target_link_libraries(libbsarch_OOP PUBLIC Qt5::Core)
|
||||
if(Qt6_FOUND)
|
||||
message("libbsarch: Qt6 found, enabling Qt support")
|
||||
target_link_libraries(libbsarch_OOP PUBLIC Qt::Core)
|
||||
target_compile_definitions(libbsarch PUBLIC "QT")
|
||||
target_compile_definitions(libbsarch_OOP PUBLIC "QT")
|
||||
endif()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+34
-29
@@ -9,6 +9,10 @@ uses
|
||||
wbBSArchive;
|
||||
|
||||
type
|
||||
TwbBSResultBuffer = packed record
|
||||
size: Cardinal;
|
||||
data: PByte;
|
||||
end;
|
||||
TwbBSResultCode = (
|
||||
BSA_RESULT_NONE = 0,
|
||||
BSA_RESULT_EXCEPTION = -1
|
||||
@@ -68,7 +72,7 @@ end;
|
||||
function bsa_entry_list_create:Pointer; stdcall;
|
||||
begin
|
||||
try
|
||||
Result := TwbBSEntryList.Create;
|
||||
Result := TStringList.Create;
|
||||
except
|
||||
Result := nil;
|
||||
end;
|
||||
@@ -78,8 +82,8 @@ function bsa_entry_list_free(obj: Pointer): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSEntryList(obj).Clear();
|
||||
TwbBSEntryList(obj).free;
|
||||
TStringList(obj).Clear();
|
||||
TStringList(obj).free;
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -89,7 +93,7 @@ end;
|
||||
function bsa_entry_list_count(obj: Pointer): Integer; stdcall;
|
||||
begin
|
||||
try
|
||||
Result := TwbBSEntryList(obj).Count;
|
||||
Result := TStringList(obj).Count;
|
||||
except
|
||||
Result := Ord(BSA_RESULT_EXCEPTION);
|
||||
end;
|
||||
@@ -99,7 +103,7 @@ function bsa_entry_list_add(obj: Pointer; const aEntryString: PChar): TwbBSResul
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSEntryList(obj).Add(String(aEntryString));
|
||||
TStringList(obj).Add(String(aEntryString));
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -109,7 +113,7 @@ end;
|
||||
function bsa_entry_list_get(obj: Pointer; const aIndex: Cardinal; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Integer; stdcall;
|
||||
begin
|
||||
try
|
||||
Result := string_to_cstring_end(TwbBSEntryList(obj).Strings[aIndex], aStringBufferSize, aStringBuffer);
|
||||
Result := string_to_cstring_end(TStringList(obj).Strings[aIndex], aStringBufferSize, aStringBuffer);
|
||||
except
|
||||
Result := Integer(BSA_RESULT_EXCEPTION);
|
||||
end;
|
||||
@@ -148,11 +152,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function bsa_create_archive(obj: Pointer; const aFilePath: PChar; aType: TBSArchiveType; aFileList: TwbBSEntryList): TwbBSResultMessage; stdcall;
|
||||
function bsa_create_archive(obj: Pointer; const aFilePath: PChar; aType: TBSArchiveType; aFileList: TStringList): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSArchive(obj).CreateArchiveCompat(String(aFilePath), aType, aFileList);
|
||||
TwbBSArchive(obj).CreateArchive(String(aFilePath), aType, aFileList);
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -193,10 +197,14 @@ begin
|
||||
end;
|
||||
|
||||
function bsa_add_file_from_memory(obj: Pointer; const aFilePath: PChar; const aSize: Cardinal; const aData: PByte): TwbBSResultMessage; stdcall;
|
||||
var
|
||||
Buffer: TBytes;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
SetLength(Buffer, aSize);
|
||||
Move(aData[0], Buffer[0], aSize);
|
||||
try
|
||||
TwbBSArchive(obj).AddFileDataCompat(String(aFilePath), aSize, aData);
|
||||
TwbBSArchive(obj).AddFileData(String(aFilePath), Buffer);
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -213,10 +221,14 @@ begin
|
||||
end;
|
||||
|
||||
function bsa_extract_file_data_by_record(obj: Pointer; aFileRecord: Pointer): TwbBSResultMessageBuffer; stdcall;
|
||||
var
|
||||
Buffer: TBytes;
|
||||
begin
|
||||
Result.message.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
Result.buffer := TwbBSArchive(obj).ExtractFileDataCompat(aFileRecord);
|
||||
Buffer := TwbBSArchive(obj).ExtractFileData(aFileRecord);
|
||||
Result.buffer.data := @Buffer[0];
|
||||
Result.buffer.size := Length(Buffer);
|
||||
except
|
||||
on E: Exception do
|
||||
buffer_exception_handler(E, Result);
|
||||
@@ -224,10 +236,14 @@ begin
|
||||
end;
|
||||
|
||||
function bsa_extract_file_data_by_filename(obj: Pointer; const aFilePath: PChar): TwbBSResultMessageBuffer; stdcall;
|
||||
var
|
||||
Buffer: TBytes;
|
||||
begin
|
||||
Result.message.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
Result.buffer := TwbBSArchive(obj).ExtractFileDataCompat(String(aFilePath));
|
||||
Buffer := TwbBSArchive(obj).ExtractFileData(String(aFilePath));
|
||||
Result.buffer.data := @Buffer[0];
|
||||
Result.buffer.size := Length(Buffer);
|
||||
except
|
||||
on E: Exception do
|
||||
buffer_exception_handler(E, Result);
|
||||
@@ -238,7 +254,8 @@ function bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSResultMessageBuff
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSArchive(obj).ReleaseFileDataCompat(fileDataResult.buffer);
|
||||
FreeMem(fileDataResult.buffer.data);
|
||||
fileDataResult.buffer.size := 0;
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -256,11 +273,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProcCompat; aContext: Pointer): TwbBSResultMessage; stdcall;
|
||||
function bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProc; aContext: Pointer): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSArchive(obj).IterateFilesCompat(aProc, aContext);
|
||||
TwbBSArchive(obj).IterateFiles(aProc, aContext);
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
@@ -276,28 +293,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function bsa_get_resource_list(obj: Pointer; const aEntryResultList: TwbBSEntryList; aFolder: PChar): TwbBSResultMessage; stdcall;
|
||||
function bsa_get_resource_list(obj: Pointer; const aEntryResultList: TStringList; aFolder: PChar): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSArchive(obj).ResourceListCompat(aEntryResultList, String(aFolder));
|
||||
TwbBSArchive(obj).ResourceList(aEntryResultList, String(aFolder));
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function bsa_resolve_hash(obj: Pointer; const aHash: UInt64; const aEntryResultList: TwbBSEntryList): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
try
|
||||
TwbBSArchive(obj).ResolveHashCompat(aHash, aEntryResultList);
|
||||
except
|
||||
on E: Exception do
|
||||
exception_handler(E, Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function bsa_close(obj: Pointer): TwbBSResultMessage; stdcall;
|
||||
begin
|
||||
Result.code := Ord(BSA_RESULT_NONE);
|
||||
@@ -374,7 +380,7 @@ begin
|
||||
TwbBSArchive(obj).ShareData := shareData;
|
||||
end;
|
||||
|
||||
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat; aContext: Pointer); stdcall;
|
||||
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProc; aContext: Pointer); stdcall;
|
||||
begin
|
||||
TwbBSArchive(obj).DDSInfoProc := aProc;
|
||||
TwbBSArchive(obj).DDSInfoProcContext := aContext;
|
||||
@@ -403,7 +409,6 @@ exports
|
||||
bsa_file_dds_info_callback_set,
|
||||
|
||||
bsa_close,
|
||||
bsa_resolve_hash,
|
||||
bsa_get_resource_list,
|
||||
bsa_file_exists,
|
||||
bsa_iterate_files,
|
||||
|
||||
+758
-8
File diff suppressed because it is too large
Load Diff
+681
-482
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,6 @@ EXPORTS
|
||||
bsa_iterate_files
|
||||
bsa_file_exists
|
||||
bsa_get_resource_list
|
||||
bsa_resolve_hash
|
||||
bsa_close
|
||||
bsa_filename_get
|
||||
bsa_archive_type_get
|
||||
|
||||
+3
-3
@@ -75,7 +75,9 @@ typedef enum bsa_archive_type_e
|
||||
baFO3,
|
||||
baSSE,
|
||||
baFO4,
|
||||
baFO4dds
|
||||
baFO4dds,
|
||||
baSF,
|
||||
baSFdds
|
||||
} bsa_archive_type_t;
|
||||
|
||||
typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive,
|
||||
@@ -123,8 +125,6 @@ bsa_iterate_files(bsa_archive_t archive, bsa_file_iteration_proc_t file_iteratio
|
||||
BSARCH_DLL_API(bool) bsa_file_exists(bsa_archive_t archive, const wchar_t *file_path);
|
||||
BSARCH_DLL_API(bsa_result_message_t)
|
||||
bsa_get_resource_list(bsa_archive_t archive, bsa_entry_list_t entry_result_list, const wchar_t *folder);
|
||||
BSARCH_DLL_API(bsa_result_message_t)
|
||||
bsa_resolve_hash(bsa_archive_t archive, uint64_t hash, bsa_entry_list_t entry_result_list);
|
||||
BSARCH_DLL_API(bsa_result_message_t) bsa_close(bsa_archive_t archive);
|
||||
|
||||
BSARCH_DLL_API(uint32_t)
|
||||
|
||||
Reference in New Issue
Block a user