Author SHA1 Message Date
Mikaël Capelle 72b5144510 Modification to use external DDS.h header in MO2. 2024-07-01 17:11:14 +02:00
11 changed files with 525 additions and 1480 deletions
+4 -6
View File
@@ -7,12 +7,11 @@ project(libbsarch CXX)
# Add library to build.
add_library(libbsarch SHARED
src/DDS.h
src/libbsarch.h
src/libbsarch.cpp
src/libbsarch.def
)
)
target_include_directories(libbsarch PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/dds)
target_compile_features(libbsarch PRIVATE cxx_std_11)
# Preprocessor definitions
@@ -50,11 +49,9 @@ add_library(libbsarch_OOP STATIC
src/bs_archive.h
src/bs_archive_entries.cpp
src/bs_archive_entries.h
src/dds.h
src/libbsarch.hpp
src/libbsarch.h
src/dds.h
src/utils/convertible_string.cpp
src/utils/convertible_string.hpp
@@ -62,7 +59,8 @@ add_library(libbsarch_OOP STATIC
src/utils/convertible_ostream.hpp
src/utils/string_convert.cpp
src/utils/string_convert.hpp
)
)
target_include_directories(libbsarch_OOP PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/dds)
## Copying the corresponding DLL ##
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29 -34
View File
@@ -9,10 +9,6 @@ uses
wbBSArchive;
type
TwbBSResultBuffer = packed record
size: Cardinal;
data: PByte;
end;
TwbBSResultCode = (
BSA_RESULT_NONE = 0,
BSA_RESULT_EXCEPTION = -1
@@ -72,7 +68,7 @@ end;
function bsa_entry_list_create:Pointer; stdcall;
begin
try
Result := TStringList.Create;
Result := TwbBSEntryList.Create;
except
Result := nil;
end;
@@ -82,8 +78,8 @@ function bsa_entry_list_free(obj: Pointer): TwbBSResultMessage; stdcall;
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TStringList(obj).Clear();
TStringList(obj).free;
TwbBSEntryList(obj).Clear();
TwbBSEntryList(obj).free;
except
on E: Exception do
exception_handler(E, Result);
@@ -93,7 +89,7 @@ end;
function bsa_entry_list_count(obj: Pointer): Integer; stdcall;
begin
try
Result := TStringList(obj).Count;
Result := TwbBSEntryList(obj).Count;
except
Result := Ord(BSA_RESULT_EXCEPTION);
end;
@@ -103,7 +99,7 @@ function bsa_entry_list_add(obj: Pointer; const aEntryString: PChar): TwbBSResul
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TStringList(obj).Add(String(aEntryString));
TwbBSEntryList(obj).Add(String(aEntryString));
except
on E: Exception do
exception_handler(E, Result);
@@ -113,7 +109,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(TStringList(obj).Strings[aIndex], aStringBufferSize, aStringBuffer);
Result := string_to_cstring_end(TwbBSEntryList(obj).Strings[aIndex], aStringBufferSize, aStringBuffer);
except
Result := Integer(BSA_RESULT_EXCEPTION);
end;
@@ -152,11 +148,11 @@ begin
end;
end;
function bsa_create_archive(obj: Pointer; const aFilePath: PChar; aType: TBSArchiveType; aFileList: TStringList): TwbBSResultMessage; stdcall;
function bsa_create_archive(obj: Pointer; const aFilePath: PChar; aType: TBSArchiveType; aFileList: TwbBSEntryList): TwbBSResultMessage; stdcall;
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TwbBSArchive(obj).CreateArchive(String(aFilePath), aType, aFileList);
TwbBSArchive(obj).CreateArchiveCompat(String(aFilePath), aType, aFileList);
except
on E: Exception do
exception_handler(E, Result);
@@ -197,14 +193,10 @@ 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).AddFileData(String(aFilePath), Buffer);
TwbBSArchive(obj).AddFileDataCompat(String(aFilePath), aSize, aData);
except
on E: Exception do
exception_handler(E, Result);
@@ -221,14 +213,10 @@ 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
Buffer := TwbBSArchive(obj).ExtractFileData(aFileRecord);
Result.buffer.data := @Buffer[0];
Result.buffer.size := Length(Buffer);
Result.buffer := TwbBSArchive(obj).ExtractFileDataCompat(aFileRecord);
except
on E: Exception do
buffer_exception_handler(E, Result);
@@ -236,14 +224,10 @@ 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
Buffer := TwbBSArchive(obj).ExtractFileData(String(aFilePath));
Result.buffer.data := @Buffer[0];
Result.buffer.size := Length(Buffer);
Result.buffer := TwbBSArchive(obj).ExtractFileDataCompat(String(aFilePath));
except
on E: Exception do
buffer_exception_handler(E, Result);
@@ -254,8 +238,7 @@ function bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSResultMessageBuff
begin
Result.code := Ord(BSA_RESULT_NONE);
try
FreeMem(fileDataResult.buffer.data);
fileDataResult.buffer.size := 0;
TwbBSArchive(obj).ReleaseFileDataCompat(fileDataResult.buffer);
except
on E: Exception do
exception_handler(E, Result);
@@ -273,11 +256,11 @@ begin
end;
end;
function bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProc; aContext: Pointer): TwbBSResultMessage; stdcall;
function bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProcCompat; aContext: Pointer): TwbBSResultMessage; stdcall;
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TwbBSArchive(obj).IterateFiles(aProc, aContext);
TwbBSArchive(obj).IterateFilesCompat(aProc, aContext);
except
on E: Exception do
exception_handler(E, Result);
@@ -293,17 +276,28 @@ begin
end;
end;
function bsa_get_resource_list(obj: Pointer; const aEntryResultList: TStringList; aFolder: PChar): TwbBSResultMessage; stdcall;
function bsa_get_resource_list(obj: Pointer; const aEntryResultList: TwbBSEntryList; aFolder: PChar): TwbBSResultMessage; stdcall;
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TwbBSArchive(obj).ResourceList(aEntryResultList, String(aFolder));
TwbBSArchive(obj).ResourceListCompat(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);
@@ -380,7 +374,7 @@ begin
TwbBSArchive(obj).ShareData := shareData;
end;
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProc; aContext: Pointer); stdcall;
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat; aContext: Pointer); stdcall;
begin
TwbBSArchive(obj).DDSInfoProc := aProc;
TwbBSArchive(obj).DDSInfoProcContext := aContext;
@@ -409,6 +403,7 @@ exports
bsa_file_dds_info_callback_set,
bsa_close,
bsa_resolve_hash,
bsa_get_resource_list,
bsa_file_exists,
bsa_iterate_files,
+8 -758
View File
File diff suppressed because it is too large Load Diff
+479 -678
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -22,6 +22,7 @@ EXPORTS
bsa_iterate_files
bsa_file_exists
bsa_get_resource_list
bsa_resolve_hash
bsa_close
bsa_filename_get
bsa_archive_type_get
+4 -4
View File
@@ -1,7 +1,7 @@
#pragma once
#include "dds.h"
#include <dxgiformat.h>
#include <dds.h>
#include <stdint.h>
#ifdef BSARCH_DLL_EXPORT
@@ -75,9 +75,7 @@ typedef enum bsa_archive_type_e
baFO3,
baSSE,
baFO4,
baFO4dds,
baSF,
baSFdds
baFO4dds
} bsa_archive_type_t;
typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive,
@@ -125,6 +123,8 @@ 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)