4 Commits
Author SHA1 Message Date
Jeremy Rimpo 701bc58e9a Merge pull request #2 from ModOrganizer2/starfield_support
Update to latest BSArch / xEdit
2024-06-24 01:03:08 -05:00
Jeremy Rimpo c535689ef4 Migrate to newer data types 2024-06-22 15:39:13 -05:00
Jeremy Rimpo 3219ade30e Update to latest BSArch / xEdit
- Supports Starfield and FO4 NG archives
- Other code improvements
- Removed some old functions
2024-06-22 05:32:40 -05:00
Jeremy Rimpo 4a88aab247 Update for Qt6 2021-12-04 04:38:23 -06:00
44 changed files with 1894 additions and 1325 deletions
-7
View File
@@ -1,7 +0,0 @@
root = true
[*]
end_of_line = crlf
insert_final_newline = true
indent_style = space
indent_size = 2
-2
View File
@@ -529,5 +529,3 @@ healthchecksdb
MigrationBackup/
# End of https://www.gitignore.io/api/qt,c++,cmake,delphi,qtcreator,visualstudio
**/build
+107
View File
@@ -0,0 +1,107 @@
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)
# Project
project(libbsarch CXX)
# Add library to build.
add_library(libbsarch SHARED
src/DDS.h
src/libbsarch.h
src/libbsarch.cpp
src/libbsarch.def
)
target_compile_features(libbsarch PRIVATE cxx_std_11)
# Preprocessor definitions
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(MSVC)
target_compile_options(libbsarch PRIVATE /W3 /MDd /Od /EHsc)
endif()
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if(MSVC)
target_compile_options(libbsarch PRIVATE /W3 /Zi /EHsc)
endif()
endif()
target_compile_definitions(libbsarch PRIVATE BSARCH_DLL_EXPORT)
#We only want the lib file. The DLL will be provided by Delphi
#Removing the generated DLL
add_custom_command(TARGET libbsarch POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove
${CMAKE_CURRENT_BINARY_DIR}/libbsarch.dll)
############################################################
# libbsarch_OOP #
############################################################
find_package(Qt6 COMPONENTS Core REQUIRED)
add_library(libbsarch_OOP STATIC
src/base_types.hpp
src/bs_archive_auto.cpp
src/bs_archive_auto.hpp
src/bs_archive.cpp
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
src/utils/convertible_ostream.cpp
src/utils/convertible_ostream.hpp
src/utils/string_convert.cpp
src/utils/string_convert.hpp
)
## Copying the corresponding DLL ##
#Finding 32 or 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# 64 bits
set(lib_delphi "${CMAKE_CURRENT_SOURCE_DIR}/delphi/lib64")
message("libbsarch: using 64bits DLL")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
# 32 bits
set(lib_delphi "${CMAKE_CURRENT_SOURCE_DIR}/delphi/lib")
message("libbsarch: using 32bits DLL")
endif()
if(copy_dll_to_binary_dir)
#Finding debug or release
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(libbsarch_dll_path "${lib_delphi}/libbsarchd.dll")
else()
set(libbsarch_dll_path "${lib_delphi}/libbsarch.dll")
endif()
#Actually copying the DLL
add_custom_command(TARGET libbsarch POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${libbsarch_dll_path}
${CMAKE_BINARY_DIR}/libbsarch.dll)
message("libbsarch: Copying the DLL to ${CMAKE_BINARY_DIR}/libbsarch.dll")
endif()
#Adding Qt support
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()
target_link_libraries(libbsarch_OOP PUBLIC libbsarch)
target_compile_features(libbsarch_OOP PRIVATE cxx_std_17)
target_compile_definitions(libbsarch_OOP PRIVATE _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
-19
View File
@@ -1,19 +0,0 @@
cmake_minimum_required(VERSION 3.17)
project("libbsarch-c99")
include(CTest)
enable_testing()
add_library(${PROJECT_NAME} INTERFACE)
add_subdirectory(../delphi .)
target_include_directories(${PROJECT_NAME} INTERFACE .)
target_link_libraries(${PROJECT_NAME} INTERFACE "libbsarch-delphi")
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
include(CPack)
-7
View File
@@ -1,7 +0,0 @@
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
// such as names of functions and macros.
// For more information see https://go.microsoft.com/fwlink/?linkid=865984
#define PACKED(datastructure) datastructure __attribute__((__packed__))
#define PACKED(datastructure) __pragma(pack(push, 1)) datastructure __pragma(pack(pop))
#define BSARCH_DLL_API(ReturnType) extern "C" __declspec(dllexport) ReturnType __stdcall
#define BSARCH_DLL_API(ReturnType) extern "C" __declspec(dllimport) ReturnType __stdcall
-118
View File
@@ -1,118 +0,0 @@
#pragma once
#include <stdint.h>
#include <dxgiformat.h>
#include "DDS.h"
#ifdef BSARCH_DLL_EXPORT
#define BSARCH_DLL_API(ReturnType) extern "C" __declspec(dllexport) ReturnType __stdcall
#else
#define BSARCH_DLL_API(ReturnType) extern "C" __declspec(dllimport) ReturnType __stdcall
#endif
#ifdef __GNUC__
#define PACKED(datastructure) datastructure __attribute__((__packed__))
#else
#define PACKED(datastructure) __pragma(pack(push, 1)) datastructure __pragma(pack(pop))
#endif
typedef enum bsa_result_code_e {
BSA_RESULT_NONE = 0,
BSA_RESULT_EXCEPTION = -1
} bsa_result_code_t;
typedef void* bsa_buffer_t;
typedef void* bsa_archive_t;
typedef void* bsa_entry_list_t;
typedef void* bsa_file_record_t;
typedef void* bsa_folder_record_t;
typedef struct bsa_dds_info_s {
uint32_t width, height, mipmaps;
} bsa_dds_info_t;
PACKED (
struct bsa_dds_header_s {
uint32_t magic; // DDS_MAGIC
struct DirectX::DDS_HEADER header;
});
typedef struct bsa_dds_header_s bsa_dds_header_t;
PACKED (
struct bsa_result_message_s {
int8_t code; // bsa_result_code_t
wchar_t text[1024];
});
typedef struct bsa_result_message_s bsa_result_message_t;
PACKED (
struct bsa_result_buffer_s {
uint32_t size;
bsa_buffer_t data;
});
typedef struct bsa_result_buffer_s bsa_result_buffer_t;
PACKED (
struct bsa_result_message_buffer_s {
bsa_result_buffer_t buffer;
bsa_result_message_t message;
});
typedef struct bsa_result_message_buffer_s bsa_result_message_buffer_t;
typedef enum bsa_archive_state_e {
stReading, stWriting
} bsa_archive_state_t;
typedef enum bsa_archive_type_e {
baNone, baTES3, baTES4, baFO3, baSSE, baFO4, baFO4dds
} bsa_archive_type_t;
typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive, const wchar_t *file_path, bsa_dds_info_t *dds_info, void *context);
typedef bool (*bsa_file_iteration_proc_t)(bsa_archive_t archive, const wchar_t *file_path, bsa_file_record_t file_record, bsa_folder_record_t folder_record, void *context);
BSARCH_DLL_API(bsa_entry_list_t) bsa_entry_list_create();
BSARCH_DLL_API(bsa_result_message_t) bsa_entry_list_free(bsa_entry_list_t entry_list);
BSARCH_DLL_API(uint32_t) bsa_entry_list_count(bsa_entry_list_t entry_list);
BSARCH_DLL_API(bsa_result_message_t) bsa_entry_list_add(bsa_entry_list_t entry_list, const wchar_t *entry_string);
BSARCH_DLL_API(uint32_t) bsa_entry_list_get(bsa_entry_list_t entry_list, uint32_t index, uint32_t string_buffer_size, const wchar_t *string_buffer);
BSARCH_DLL_API(bsa_archive_t) bsa_create();
BSARCH_DLL_API(bsa_result_message_t) bsa_free(bsa_archive_t archive);
BSARCH_DLL_API(bsa_result_message_t) bsa_load_from_file(bsa_archive_t archive, const wchar_t *file_path);
BSARCH_DLL_API(bsa_result_message_t) bsa_create_archive(bsa_archive_t archive, const wchar_t *file_path, bsa_archive_type_t archive_type, bsa_entry_list_t entry_list);
BSARCH_DLL_API(bsa_result_message_t) bsa_save(bsa_archive_t archive);
BSARCH_DLL_API(bsa_result_message_t) bsa_add_file_from_disk(bsa_archive_t archive, const wchar_t *file_path, const wchar_t *source_path);
BSARCH_DLL_API(bsa_result_message_t) bsa_add_file_from_disk_root(bsa_archive_t archive, const wchar_t *root_dir, const wchar_t *source_path);
BSARCH_DLL_API(bsa_result_message_t) bsa_add_file_from_memory(bsa_archive_t archive, const wchar_t *file_path, uint32_t size, bsa_buffer_t data);
BSARCH_DLL_API(bsa_file_record_t) bsa_find_file_record(bsa_archive_t archive, const wchar_t *file_path);
BSARCH_DLL_API(bsa_result_message_buffer_t) bsa_extract_file_data_by_record(bsa_archive_t archive, bsa_file_record_t file_record);
BSARCH_DLL_API(bsa_result_message_buffer_t) bsa_extract_file_data_by_filename(bsa_archive_t archive, const wchar_t *file_path);
BSARCH_DLL_API(bsa_result_message_t) bsa_file_data_free(bsa_archive_t archive, bsa_result_buffer_t file_data_result);
BSARCH_DLL_API(bsa_result_message_t) bsa_extract_file(bsa_archive_t archive, const wchar_t *file_path, const wchar_t *save_as);
BSARCH_DLL_API(bsa_result_message_t) bsa_iterate_files(bsa_archive_t archive, bsa_file_iteration_proc_t file_iteration_proc, void *context);
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) bsa_filename_get(bsa_archive_t archive, uint32_t string_buffer_size, const wchar_t *string_buffer);
BSARCH_DLL_API(bsa_archive_type_t) bsa_archive_type_get(bsa_archive_t archive);
BSARCH_DLL_API(uint32_t) bsa_version_get(bsa_archive_t archive);
BSARCH_DLL_API(uint32_t) bsa_format_name_get(bsa_archive_t archive, uint32_t string_buffer_size, const wchar_t *string_buffer);
BSARCH_DLL_API(uint32_t) bsa_file_count_get(bsa_archive_t archive);
BSARCH_DLL_API(uint32_t) bsa_archive_flags_get(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_archive_flags_set(bsa_archive_t archive, uint32_t flags);
BSARCH_DLL_API(uint32_t) bsa_file_flags_get(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_file_flags_set(bsa_archive_t archive, uint32_t flags);
BSARCH_DLL_API(bool) bsa_compress_get(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_compress_set(bsa_archive_t archive, bool flags);
BSARCH_DLL_API(bool) bsa_share_data_get(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_share_data_set(bsa_archive_t archive, bool flags);
BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc, void *context);
-31
View File
@@ -1,31 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbsarch", "libbsarch.vcxproj", "{537F42AD-5B15-4671-B99E-2D1818999A98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{537F42AD-5B15-4671-B99E-2D1818999A98}.Debug|x64.ActiveCfg = Debug|x64
{537F42AD-5B15-4671-B99E-2D1818999A98}.Debug|x64.Build.0 = Debug|x64
{537F42AD-5B15-4671-B99E-2D1818999A98}.Debug|x86.ActiveCfg = Debug|Win32
{537F42AD-5B15-4671-B99E-2D1818999A98}.Debug|x86.Build.0 = Debug|Win32
{537F42AD-5B15-4671-B99E-2D1818999A98}.Release|x64.ActiveCfg = Release|x64
{537F42AD-5B15-4671-B99E-2D1818999A98}.Release|x64.Build.0 = Release|x64
{537F42AD-5B15-4671-B99E-2D1818999A98}.Release|x86.ActiveCfg = Release|Win32
{537F42AD-5B15-4671-B99E-2D1818999A98}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {274A40A7-F42F-40A4-A8BD-2DA20258DB0A}
EndGlobalSection
EndGlobal
-165
View File
@@ -1,165 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{537F42AD-5B15-4671-B99E-2D1818999A98}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(DirectXTexPath)\DirectXTex;$(IncludePath)</IncludePath>
<TargetName>$(ProjectName)</TargetName>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(DirectXTexPath)\DirectXTex;$(IncludePath)</IncludePath>
<TargetName>$(ProjectName)</TargetName>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(DirectXTexPath)\DirectXTex;$(IncludePath)</IncludePath>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(DirectXTexPath)\DirectXTex;$(IncludePath)</IncludePath>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBBSARCH_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<ModuleDefinitionFile>libbsarch.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>xcopy /y "$(ProjectDir)libbsarch.h" "$(OutDir)"</Command>
<Message>Copying header file</Message>
<Outputs>$(OutDir)libbsarch.h</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBBSARCH_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>libbsarch.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>xcopy /y "$(ProjectDir)libbsarch.h" "$(OutDir)"</Command>
<Message>Copying header file</Message>
<Outputs>$(OutDir)libbsarch.h</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ModuleDefinitionFile>libbsarch.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>xcopy /y "$(ProjectDir)libbsarch.h" "$(OutDir)"</Command>
<Message>Copying header file</Message>
<Outputs>$(OutDir)libbsarch.h</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<ModuleDefinitionFile>libbsarch.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>xcopy /y "$(ProjectDir)libbsarch.h" "$(OutDir)"</Command>
<Message>Copying header file</Message>
<Outputs>$(OutDir)libbsarch.h</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
<None Include=".vscode\ipch\c1c5ff332820ca89\mmap_address.bin" />
<None Include="cpp.hint" />
<None Include="libbsarch.def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="DDS.h" />
<ClInclude Include="libbsarch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="libbsarch.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-39
View File
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="libbsarch.def">
<Filter>Source Files</Filter>
</None>
<None Include=".vscode\ipch\c1c5ff332820ca89\mmap_address.bin">
<Filter>Resource Files</Filter>
</None>
<None Include="cpp.hint" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="DDS.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="libbsarch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="libbsarch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
@@ -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,21 +236,26 @@ 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);
end;
end;
function bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSResultBuffer): TwbBSResultMessage; stdcall;
function bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSResultMessageBuffer): TwbBSResultMessage; stdcall;
begin
Result.code := Ord(BSA_RESULT_NONE);
try
TwbBSArchive(obj).ReleaseFileDataCompat(fileDataResult);
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,
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1 +0,0 @@
libbsarch.res
-45
View File
@@ -1,45 +0,0 @@
cmake_minimum_required(VERSION 3.17)
project("libbsarch-delphi" NONE)
include(CTest)
enable_testing()
add_library(${PROJECT_NAME} INTERFACE)
# Finding 32 or 64 bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# 64 bits
set(LIBBSARCH_DELPHI_DLL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib64)
message("Using 64 bits Delphi DLL")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
# 32 bits
set(LIBBSARCH_DELPHI_DLL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib32)
message("Using 32 bits Delphi DLL")
endif()
# Finding debug or release
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(LIBBSARCH_DELPHI_DLL_PATH ${LIBBSARCH_DELPHI_DLL_DIR}/debug/libbsarch.dll)
message("Using debug Delphi DLL")
else()
set(LIBBSARCH_DELPHI_DLL_PATH ${LIBBSARCH_DELPHI_DLL_DIR}/release/libbsarch.dll)
message("Using release Delphi DLL")
endif()
# Actually copying the DLL
add_custom_command(
COMMENT "Copying Delphi DLL"
DEPENDS ${LIBBSARCH_DELPHI_DLL_PATH}
OUTPUT ${CMAKE_BINARY_DIR}/libbsarch.dll
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBBSARCH_DELPHI_DLL_PATH} ${CMAKE_BINARY_DIR}/libbsarch.dll
)
add_custom_target("copy_delphi_dll" ALL DEPENDS ${CMAKE_BINARY_DIR}/libbsarch.dll)
add_dependencies(${PROJECT_NAME} "copy_delphi_dll")
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
include(CPack)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More