6 Commits
Author SHA1 Message Date
Deorder 322b6c0302 Merge branch 'master' of github-deorder:deorder/libbsarch 2019-04-15 04:17:41 +02:00
Deorder 6fe376e887 Fixed access violation issue in bsarch
Fixed C calls to use UTF-8, wide char
Changed some pointer to pointer to just pointers
Added test project
2019-04-15 04:16:36 +02:00
Deorder bd0ab57f6d Merge pull request #1 from deorder/add-license-1
Create LICENSE
2019-04-10 05:49:33 +02:00
Deorder 08536255ff Create LICENSE 2019-04-10 05:49:07 +02:00
Deorder 30b4a2eb8d Update README.md 2019-04-10 05:45:16 +02:00
Deorder f92b4cdb28 Update README.md 2019-04-10 05:44:17 +02:00
15 changed files with 482 additions and 118 deletions
+3
View File
@@ -442,3 +442,6 @@ healthchecksdb
MigrationBackup/
# End of https://www.gitignore.io/api/vim,delphi,visualstudio,visualstudiocode
libbsarch_delphi*
libbsarch_test.pas
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Deorder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+5
View File
@@ -10,3 +10,8 @@ BSArchive Dynamic Link Library and C++ bindings
## How to use
Use the `libbsarch.dll` (The one created by Delphi, not Visual Studio), `libbsarch.lib` and `libbsarch.h` in your project.
## Credits
The original BSArchive can be found at: https://github.com/TES5Edit/TES5Edit/tree/dev/Tools/BSArchive
The version in this project had been modified for better compatibility with C/C++ and allow the users to allocate their own memory in some cases.
View File
+28
View File
@@ -0,0 +1,28 @@
#include <iostream>
#include "libbsarch.h"
using namespace std::string_literals;
#pragma comment(lib, "libbsarch")
int main() {
bsa_archive_t archive = bsa_create();
bsa_load_from_file(archive, L"test_read.bsa");
bsa_close(archive);
bsa_entry_list_t entries = bsa_entry_list_create();
bsa_entry_list_add(entries, L"textures\\grass\\test.dds");
bsa_create_archive(archive, L"test_write.bsa", baSSE, entries);
bsa_add_file_from_disk(archive, L"files", L"files\\textures\\grass\\test.dds");
bsa_save(archive);
bsa_close(archive);
bsa_entry_list_free(entries);
bsa_free(archive);
printf("test\n");
}
+31
View File
@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbsarch-visualstudio-test", "libbsarch-visualstudio-test.vcxproj", "{8F73F848-939D-4862-B58B-26572CF20A5F}"
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
{8F73F848-939D-4862-B58B-26572CF20A5F}.Debug|x64.ActiveCfg = Debug|x64
{8F73F848-939D-4862-B58B-26572CF20A5F}.Debug|x64.Build.0 = Debug|x64
{8F73F848-939D-4862-B58B-26572CF20A5F}.Debug|x86.ActiveCfg = Debug|Win32
{8F73F848-939D-4862-B58B-26572CF20A5F}.Debug|x86.Build.0 = Debug|Win32
{8F73F848-939D-4862-B58B-26572CF20A5F}.Release|x64.ActiveCfg = Release|x64
{8F73F848-939D-4862-B58B-26572CF20A5F}.Release|x64.Build.0 = Release|x64
{8F73F848-939D-4862-B58B-26572CF20A5F}.Release|x86.ActiveCfg = Release|Win32
{8F73F848-939D-4862-B58B-26572CF20A5F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F05F0FBF-790B-4443-B2EC-E7033074D9E0}
EndGlobalSection
EndGlobal
+176
View File
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" 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>16.0</VCProjectVersion>
<ProjectGuid>{8F73F848-939D-4862-B58B-26572CF20A5F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libbsarchvisualstudiotest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>libbsarch-visualstudio-test</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</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>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<ReferencePath>$(OutDir);$(ReferencePath)</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
<ReferencePath>$(OutDir);$(ReferencePath)</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<ReferencePath>$(OutDir);$(ReferencePath)</ReferencePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
<ReferencePath>$(OutDir);$(ReferencePath)</ReferencePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="libbsarch-visualstudio-test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,22 @@
<?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;ipp;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;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="libbsarch-visualstudio-test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+27 -27
View File
@@ -8,19 +8,19 @@ BSARCH_DLL_API(bsa_entry_list_t) bsa_entry_list_create() {
return NULL;
}
BSARCH_DLL_API(void) bsa_entry_list_free(bsa_entry_list_t *entry_list) {
BSARCH_DLL_API(void) bsa_entry_list_free(bsa_entry_list_t entry_list) {
return;
}
BSARCH_DLL_API(uint32_t) bsa_entry_list_count(bsa_entry_list_t *entry_list) {
BSARCH_DLL_API(uint32_t) bsa_entry_list_count(bsa_entry_list_t entry_list) {
return 0;
}
BSARCH_DLL_API(void) bsa_entry_list_add(bsa_entry_list_t *entry_list, char *entry_string) {
BSARCH_DLL_API(void) bsa_entry_list_add(bsa_entry_list_t entry_list, const wchar_t *entry_string) {
return;
}
BSARCH_DLL_API(uint32_t) bsa_entry_list_get(bsa_entry_list_t *entry_list, uint32_t index, uint32_t string_buffer_size, char *string_buffer) {
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) {
return 0;
}
@@ -32,11 +32,11 @@ BSARCH_DLL_API(void) bsa_free(bsa_archive_t archive) {
return;
}
BSARCH_DLL_API(void) bsa_load_from_file(bsa_archive_t archive, char *filename) {
BSARCH_DLL_API(void) bsa_load_from_file(bsa_archive_t archive, const wchar_t *filename) {
return;
}
BSARCH_DLL_API(void) bsa_create_archive(bsa_archive_t archive, char *filename, bsa_archive_type_t archive_type, bsa_entry_list_t entry_list) {
BSARCH_DLL_API(void) bsa_create_archive(bsa_archive_t archive, const wchar_t *filename, bsa_archive_type_t archive_type, bsa_entry_list_t entry_list) {
return;
}
@@ -44,15 +44,15 @@ BSARCH_DLL_API(void) bsa_save(bsa_archive_t archive) {
return;
}
BSARCH_DLL_API(void) bsa_add_file_from_disk(bsa_archive_t archive, char *root_dir, char *filename) {
BSARCH_DLL_API(void) bsa_add_file_from_disk(bsa_archive_t archive, const wchar_t *root_dir, const wchar_t *filename) {
return;
}
BSARCH_DLL_API(void) bsa_add_file_from_memory(bsa_archive_t archive, char *filename, uint32_t size, bsa_file_data_t data) {
BSARCH_DLL_API(void) bsa_add_file_from_memory(bsa_archive_t archive, const wchar_t *filename, uint32_t size, bsa_file_data_t data) {
return;
}
BSARCH_DLL_API(bsa_file_record_t) bsa_find_file_record(bsa_archive_t archive, char *filename) {
BSARCH_DLL_API(bsa_file_record_t) bsa_find_file_record(bsa_archive_t archive, const wchar_t *filename) {
return NULL;
}
@@ -60,7 +60,7 @@ BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_record(bsa_archi
return { 0 };
}
BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_filename(bsa_archive_t archive, char *filename) {
BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_filename(bsa_archive_t archive, const wchar_t *filename) {
return { 0 };
}
@@ -68,7 +68,7 @@ BSARCH_DLL_API(void) bsa_file_data_free(bsa_archive_t archive, bsa_file_data_res
return;
}
BSARCH_DLL_API(void) bsa_extract_file(bsa_archive_t archive, char *filename, char *save_as) {
BSARCH_DLL_API(void) bsa_extract_file(bsa_archive_t archive, const wchar_t *filename, const wchar_t *save_as) {
return;
}
@@ -76,11 +76,11 @@ BSARCH_DLL_API(void) bsa_iterate_files(bsa_archive_t archive, bsa_file_iteration
return;
}
BSARCH_DLL_API(bool) bsa_file_exists(bsa_archive_t archive, char *filename) {
BSARCH_DLL_API(bool) bsa_file_exists(bsa_archive_t archive, const wchar_t *filename) {
return false;
}
BSARCH_DLL_API(void) bsa_get_resource_list(bsa_archive_t archive, bsa_entry_list_t entry_result_list, char *folder) {
BSARCH_DLL_API(void) bsa_get_resource_list(bsa_archive_t archive, bsa_entry_list_t entry_result_list, const wchar_t *folder) {
return;
}
@@ -92,58 +92,58 @@ BSARCH_DLL_API(void) bsa_close(bsa_archive_t archive) {
return;
}
BSARCH_DLL_API(uint32_t) bsa_filename_get(bsa_archive_t *archive, uint32_t string_buffer_size, char *string_buffer) {
BSARCH_DLL_API(uint32_t) bsa_filename_get(bsa_archive_t archive, uint32_t string_buffer_size, const wchar_t *string_buffer) {
return 0;
}
BSARCH_DLL_API(bsa_archive_type_t) bsa_archive_type_get(bsa_archive_t *archive) {
BSARCH_DLL_API(bsa_archive_type_t) bsa_archive_type_get(bsa_archive_t archive) {
return bsa_archive_type_t::baNone;
}
BSARCH_DLL_API(uint32_t) bsa_version_get(bsa_archive_t *archive) {
BSARCH_DLL_API(uint32_t) bsa_version_get(bsa_archive_t archive) {
return 0;
}
BSARCH_DLL_API(uint32_t) bsa_format_name_get(bsa_archive_t *archive, uint32_t string_buffer_size, char *string_buffer) {
BSARCH_DLL_API(uint32_t) bsa_format_name_get(bsa_archive_t archive, uint32_t string_buffer_size, const wchar_t *string_buffer) {
return 0;
}
BSARCH_DLL_API(uint32_t) bsa_file_count_get(bsa_archive_t *archive) {
BSARCH_DLL_API(uint32_t) bsa_file_count_get(bsa_archive_t archive) {
return 0;
}
BSARCH_DLL_API(uint32_t) bsa_archive_flags_get(bsa_archive_t *archive) {
BSARCH_DLL_API(uint32_t) bsa_archive_flags_get(bsa_archive_t archive) {
return 0;
}
BSARCH_DLL_API(void) bsa_archive_flags_set(bsa_archive_t *archive, uint32_t flags) {
BSARCH_DLL_API(void) bsa_archive_flags_set(bsa_archive_t archive, uint32_t flags) {
return;
}
BSARCH_DLL_API(uint32_t) bsa_file_flags_get(bsa_archive_t *archive) {
BSARCH_DLL_API(uint32_t) bsa_file_flags_get(bsa_archive_t archive) {
return 0;
}
BSARCH_DLL_API(void) bsa_file_flags_set(bsa_archive_t *archive, uint32_t flags) {
BSARCH_DLL_API(void) bsa_file_flags_set(bsa_archive_t archive, uint32_t flags) {
return;
}
BSARCH_DLL_API(bool) bsa_compress_get(bsa_archive_t *archive) {
BSARCH_DLL_API(bool) bsa_compress_get(bsa_archive_t archive) {
return false;
}
BSARCH_DLL_API(void) bsa_compress_set(bsa_archive_t *archive, bool flags) {
BSARCH_DLL_API(void) bsa_compress_set(bsa_archive_t archive, bool flags) {
return;
}
BSARCH_DLL_API(bool) bsa_share_data_get(bsa_archive_t *archive) {
BSARCH_DLL_API(bool) bsa_share_data_get(bsa_archive_t archive) {
return false;
}
BSARCH_DLL_API(void) bsa_share_data_set(bsa_archive_t *archive, bool flags) {
BSARCH_DLL_API(void) bsa_share_data_set(bsa_archive_t archive, bool flags) {
return;
}
BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t *archive, bsa_file_dds_info_proc_t file_dds_info_proc) {
BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc) {
return;
}
+1 -1
View File
@@ -1,4 +1,4 @@
LIBRARY LIBBSARCH_DLL
LIBRARY LIBBSARCH
;DESCRIPTION "BSArch DLL"
EXPORTS
bsa_entry_list_create
+39 -43
View File
@@ -5,17 +5,13 @@ uses
Classes,
Types,
SysUtils,
wbStreams in 'wbStreams.pas',
wbBSArchive in './wbBSArchive.pas';
{$IFDEF FPC}
{$mode delphi}{$H+}
{$ENDIF}
wbStreams,
wbBSArchive;
{Shared}
function string_to_cstring(aString: String; const aStringBufferSize: Cardinal;
const aStringBuffer: PChar): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
const aStringBuffer: PChar): Cardinal; stdcall;
begin
Result := Min(aStringBufferSize, Length(AString));
if (aStringBuffer <> nil) and (Result > 0) then
@@ -24,185 +20,185 @@ end;
{BSA File List}
function bsa_entry_list_create:Pointer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_entry_list_create:Pointer; stdcall;
begin
Result := TwbBSEntryList.Create;
end;
procedure bsa_entry_list_free(obj: Pointer); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_entry_list_free(obj: Pointer); stdcall;
begin
TwbBSEntryList(obj).Clear();
TwbBSEntryList(obj).free;
end;
function bsa_entry_list_count(obj: Pointer): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_entry_list_count(obj: Pointer): Cardinal; stdcall;
begin
Result := TwbBSEntryList(obj).Count;
end;
procedure bsa_entry_list_add(obj: Pointer; const aEntryString: PChar); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_entry_list_add(obj: Pointer; const aEntryString: PChar); stdcall;
begin
TwbBSEntryList(obj).Add(String(aEntryString));
end;
function bsa_entry_list_get(obj: Pointer; const aIndex: Cardinal; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_entry_list_get(obj: Pointer; const aIndex: Cardinal; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; stdcall;
begin
Result := string_to_cstring(TwbBSEntryList(obj).Strings[aIndex], aStringBufferSize, aStringBuffer);
end;
{BSArchive}
function bsa_create:Pointer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_create:Pointer; stdcall;
begin
Result := TwbBSArchive.Create;
end;
procedure bsa_free(obj: Pointer); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_free(obj: Pointer); stdcall;
begin
TwbBSArchive(obj).free;
end;
procedure bsa_load_from_file(obj: Pointer; const aFileName: PChar); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_load_from_file(obj: Pointer; const aFileName: PChar); stdcall;
begin
TwbBSArchive(obj).LoadFromFile(String(aFileName));
end;
procedure bsa_create_archive(obj: Pointer; const aFileName: PChar; aType: TBSArchiveType; aFileList: TwbBSEntryList); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_create_archive(obj: Pointer; const aFileName: PChar; aType: TBSArchiveType; aFileList: TwbBSEntryList); stdcall;
begin
TwbBSArchive(obj).CreateArchiveCompat(String(aFileName), aType, aFileList);
end;
procedure bsa_save(obj: Pointer); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_save(obj: Pointer); stdcall;
begin
TwbBSArchive(obj).Save;
end;
procedure bsa_add_file_from_disk(obj: Pointer; const aRootDir, aFileName: PChar); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_add_file_from_disk(obj: Pointer; const aRootDir, aFileName: PChar); stdcall;
begin
TwbBSArchive(obj).AddFile(String(aRootDir), String(aFileName));
end;
procedure bsa_add_file_from_memory(obj: Pointer; const aFileName: PChar; const aSize: Cardinal; const aData: PByte); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_add_file_from_memory(obj: Pointer; const aFileName: PChar; const aSize: Cardinal; const aData: PByte); stdcall;
begin
TwbBSArchive(obj).AddFileCompat(String(aFileName), aSize, aData);
end;
function bsa_find_file_record(obj: Pointer; const aFileName: PChar): Pointer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_find_file_record(obj: Pointer; const aFileName: PChar): Pointer; stdcall;
begin
Result := TwbBSArchive(obj).FindFileRecord(String(aFileName));
end;
function bsa_extract_file_data_by_record(obj: Pointer; aFileRecord: Pointer): TwbBSFileDataResult; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_extract_file_data_by_record(obj: Pointer; aFileRecord: Pointer): TwbBSFileDataResult; stdcall;
begin
Result := TwbBSArchive(obj).ExtractFileDataCompat(aFileRecord);
end;
function bsa_extract_file_data_by_filename(obj: Pointer; const aFileName: PChar): TwbBSFileDataResult; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_extract_file_data_by_filename(obj: Pointer; const aFileName: PChar): TwbBSFileDataResult; stdcall;
begin
Result := TwbBSArchive(obj).ExtractFileDataCompat(String(aFileName));
end;
procedure bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSFileDataResult); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_file_data_free(obj: Pointer; fileDataResult: TwbBSFileDataResult); stdcall;
begin
TwbBSArchive(obj).ReleaseFileDataCompat(fileDataResult);
end;
procedure bsa_extract_file(obj: Pointer; const aFileName, aSaveAs: PChar); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_extract_file(obj: Pointer; const aFileName, aSaveAs: PChar); stdcall;
begin
TwbBSArchive(obj).ExtractFile(String(aFileName), String(aSaveAs));
end;
procedure bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProcCompat; aContext: Pointer); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_iterate_files(obj: Pointer; aProc: TBSFileIterationProcCompat; aContext: Pointer); stdcall;
begin
TwbBSArchive(obj).IterateFilesCompat(aProc, aContext);
end;
function bsa_file_exists(obj: Pointer; const aFileName: string): Boolean; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_file_exists(obj: Pointer; const aFileName: string): Boolean; stdcall;
begin
Result := TwbBSArchive(obj).FileExists(aFileName);
end;
procedure bsa_get_resource_list(obj: Pointer; const aEntryResultList: TwbBSEntryList; aFolder: PChar); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_get_resource_list(obj: Pointer; const aEntryResultList: TwbBSEntryList; aFolder: PChar); stdcall;
begin
TwbBSArchive(obj).ResourceListCompat(aEntryResultList, String(aFolder));
end;
procedure bsa_resolve_hash(obj: Pointer; const aHash: UInt64; const aEntryResultList: TwbBSEntryList); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_resolve_hash(obj: Pointer; const aHash: UInt64; const aEntryResultList: TwbBSEntryList); stdcall;
begin
TwbBSArchive(obj).ResolveHashCompat(aHash, aEntryResultList);
end;
procedure bsa_close(obj: Pointer); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_close(obj: Pointer); stdcall;
begin
TwbBSArchive(obj).Close;
end;
function bsa_filename_get(obj: Pointer; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_filename_get(obj: Pointer; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; stdcall;
begin
Result := string_to_cstring(TwbBSArchive(obj).FileName, aStringBufferSize, aStringBuffer);
end;
function bsa_archive_type_get(obj: Pointer): TBSArchiveType; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_archive_type_get(obj: Pointer): TBSArchiveType; stdcall;
begin
Result := TwbBSArchive(obj).ArchiveType;
end;
function bsa_version_get(obj: Pointer): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_version_get(obj: Pointer): Cardinal; stdcall;
begin
Result := TwbBSArchive(obj).Version;
end;
function bsa_format_name_get(obj: Pointer; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_format_name_get(obj: Pointer; const aStringBufferSize: Cardinal; const aStringBuffer: PChar): Cardinal; stdcall;
begin
Result := string_to_cstring(TwbBSArchive(obj).FormatName, aStringBufferSize, aStringBuffer);
end;
function bsa_file_count_get(obj: Pointer): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_file_count_get(obj: Pointer): Cardinal; stdcall;
begin
Result := TwbBSArchive(obj).FileCount;
end;
function bsa_archive_flags_get(obj: Pointer): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_archive_flags_get(obj: Pointer): Cardinal; stdcall;
begin
Result := TwbBSArchive(obj).ArchiveFlags;
end;
procedure bsa_archive_flags_set(obj: Pointer; flags: Cardinal); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_archive_flags_set(obj: Pointer; flags: Cardinal); stdcall;
begin
TwbBSArchive(obj).ArchiveFlags := flags;
end;
function bsa_file_flags_get(obj: Pointer): Cardinal; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_file_flags_get(obj: Pointer): Cardinal; stdcall;
begin
Result := TwbBSArchive(obj).FileFlags;
end;
procedure bsa_file_flags_set(obj: Pointer; flags: Cardinal); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_file_flags_set(obj: Pointer; flags: Cardinal); stdcall;
begin
TwbBSArchive(obj).FileFlags := flags;
end;
function bsa_compress_get(obj: Pointer): Boolean; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_compress_get(obj: Pointer): Boolean; stdcall;
begin
Result := TwbBSArchive(obj).Compress;
end;
procedure bsa_compress_set(obj: Pointer; compress: Boolean); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_compress_set(obj: Pointer; compress: Boolean); stdcall;
begin
TwbBSArchive(obj).Compress := compress;
end;
function bsa_share_data_get(obj: Pointer): Boolean; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
function bsa_share_data_get(obj: Pointer): Boolean; stdcall;
begin
Result := TwbBSArchive(obj).ShareData;
end;
procedure bsa_share_data_set(obj: Pointer; shareData: Boolean); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_share_data_set(obj: Pointer; shareData: Boolean); stdcall;
begin
TwbBSArchive(obj).ShareData := shareData;
end;
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat); stdcall;
begin
TwbBSArchive(obj).DDSInfoProc := aProc;
end;
+42 -3
View File
@@ -8,7 +8,7 @@
<AppType>Library</AppType>
<FrameworkType>None</FrameworkType>
<ProjectVersion>18.6</ProjectVersion>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
@@ -28,11 +28,29 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
<Cfg_1_Win32>true</Cfg_1_Win32>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win64)'!=''">
<Cfg_1_Win64>true</Cfg_1_Win64>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
<Cfg_2_Win32>true</Cfg_2_Win32>
<CfgParent>Cfg_2</CfgParent>
<Cfg_2>true</Cfg_2>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win64)'!=''">
<Cfg_2_Win64>true</Cfg_2_Win64>
<CfgParent>Cfg_2</CfgParent>
@@ -72,22 +90,43 @@
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_ExeOutput>Win32\Release\</DCC_ExeOutput>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
<Manifest_File>(None)</Manifest_File>
<Debugger_HostApplication>Win32\Release\libbsarch-visualstudio-test.exe</Debugger_HostApplication>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<DCC_ExeOutput>X64\Release\</DCC_ExeOutput>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Manifest_File>(None)</Manifest_File>
<Debugger_HostApplication>X64\Release\libbsarch-visualstudio-test.exe</Debugger_HostApplication>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_Optimize>false</DCC_Optimize>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<Debugger_HostApplication>Win32\Debug\libbsarch-visualstudio-test.exe</Debugger_HostApplication>
<DCC_ExeOutput>Win32\Debug\</DCC_ExeOutput>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
<Manifest_File>(None)</Manifest_File>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Manifest_File>(None)</Manifest_File>
<DCC_ExeOutput>X64\Debug\</DCC_ExeOutput>
<Debugger_HostApplication>X64\Debug\libbsarch-visualstudio-test.exe</Debugger_HostApplication>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="wbStreams.pas"/>
<DCCReference Include="wbBSArchive.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
+29 -29
View File
@@ -40,45 +40,45 @@ 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 bsa_archive, char **filename, bsa_dds_info_t dds_info);
typedef bool (*bsa_file_iteration_proc_t)(bsa_archive_t bsa_archive, char **filename, bsa_file_record_t file_record, bsa_folder_record_t folder_record, void *context);
typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive, const wchar_t *filename, bsa_dds_info_t dds_info);
typedef bool (*bsa_file_iteration_proc_t)(bsa_archive_t archive, const wchar_t *filename, 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(void) 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(void) bsa_entry_list_add(bsa_entry_list_t *entry_list, char *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, char *string_buffer);
BSARCH_DLL_API(void) 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(void) 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(void) bsa_free(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_load_from_file(bsa_archive_t archive, char *filename);
BSARCH_DLL_API(void) bsa_create_archive(bsa_archive_t archive, char *filename, bsa_archive_type_t archive_type, bsa_entry_list_t entry_list);
BSARCH_DLL_API(void) bsa_load_from_file(bsa_archive_t archive, const wchar_t *filename);
BSARCH_DLL_API(void) bsa_create_archive(bsa_archive_t archive, const wchar_t *filename, bsa_archive_type_t archive_type, bsa_entry_list_t entry_list);
BSARCH_DLL_API(void) bsa_save(bsa_archive_t archive);
BSARCH_DLL_API(void) bsa_add_file_from_disk(bsa_archive_t archive, char *root_dir, char *filename);
BSARCH_DLL_API(void) bsa_add_file_from_memory(bsa_archive_t archive, char *filename, uint32_t size, bsa_file_data_t data);
BSARCH_DLL_API(bsa_file_record_t) bsa_find_file_record(bsa_archive_t archive, char *filename);
BSARCH_DLL_API(void) bsa_add_file_from_disk(bsa_archive_t archive, const wchar_t *root_dir, const wchar_t *filename);
BSARCH_DLL_API(void) bsa_add_file_from_memory(bsa_archive_t archive, const wchar_t *filename, uint32_t size, bsa_file_data_t data);
BSARCH_DLL_API(bsa_file_record_t) bsa_find_file_record(bsa_archive_t archive, const wchar_t *filename);
BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_record(bsa_archive_t archive, bsa_file_record_t file_record);
BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_filename(bsa_archive_t archive, char *filename);
BSARCH_DLL_API(bsa_file_data_result_t) bsa_extract_file_data_by_filename(bsa_archive_t archive, const wchar_t *filename);
BSARCH_DLL_API(void) bsa_file_data_free(bsa_archive_t archive, bsa_file_data_result_t file_data_result);
BSARCH_DLL_API(void) bsa_extract_file(bsa_archive_t archive, char *filename, char *save_as);
BSARCH_DLL_API(void) bsa_extract_file(bsa_archive_t archive, const wchar_t *filename, const wchar_t *save_as);
BSARCH_DLL_API(void) 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, char *filename);
BSARCH_DLL_API(void) bsa_get_resource_list(bsa_archive_t archive, bsa_entry_list_t entry_result_list, char *folder);
BSARCH_DLL_API(bool) bsa_file_exists(bsa_archive_t archive, const wchar_t *filename);
BSARCH_DLL_API(void) bsa_get_resource_list(bsa_archive_t archive, bsa_entry_list_t entry_result_list, const wchar_t *folder);
BSARCH_DLL_API(void) bsa_resolve_hash(bsa_archive_t archive, uint64_t hash, bsa_entry_list_t entry_result_list);
BSARCH_DLL_API(void) bsa_close(bsa_archive_t archive);
BSARCH_DLL_API(uint32_t) bsa_filename_get(bsa_archive_t *archive, uint32_t string_buffer_size, char *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, char *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(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);
BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc);
+43 -6
View File
@@ -22,28 +22,28 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{537F42AD-5B15-4671-B99E-2D1818999A98}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<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>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -67,11 +67,15 @@
<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>
@@ -91,9 +95,15 @@
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<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>
@@ -108,7 +118,34 @@
<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" />
+15 -9
View File
@@ -194,11 +194,11 @@ type
TBSArchiveState = (stReading, stWriting);
TBSArchiveStates = set of TBSArchiveState;
TBSFileIterationProcCompat = function(aArchive: Pointer; const aFileName: PChar;
aFileRecord: Pointer; aFolderRecord: Pointer; aContext: Pointer): Boolean; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
aFileRecord: Pointer; aFolderRecord: Pointer; aContext: Pointer): Boolean; stdcall;
TDDSInfo = record Width, Height, MipMaps: Integer; end;
TBSFileDDSInfoProcCompat = procedure(aArchive: Pointer; const aFileName: PChar;
var aInfo: TDDSInfo); {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
var aInfo: TDDSInfo); stdcall;
TwbBSHeaderTES3 = packed record
HashOffset: Cardinal;
@@ -1536,7 +1536,8 @@ procedure TwbBSArchive.AddFile(const aRootDir, aFileName: string);
var
fname: string;
i: integer;
Buffer: PByte;
buffer: PByte;
stream: TFileStream;
begin
if not (stWriting in fStates) then
raise Exception.Create('Archive is not in writing mode');
@@ -1547,13 +1548,18 @@ begin
fname := Copy(aFileName, i + 1, Length(aFileName));
with TFileStream.Create(aFileName, fmOpenRead + fmShareDenyNone) do try
GetMem(Buffer, Size);
Read(Buffer[0], Size);
AddFileCompat(fname, Size, Buffer);
stream := TFileStream.Create(aFileName, fmOpenRead + fmShareDenyNone);
try
GetMem(buffer, stream.Size);
try
stream.Read(buffer^, stream.Size);
AddFileCompat(fname, stream.Size, buffer);
finally
if Assigned(buffer) then
FreeMem(buffer);
end;
finally
FreeAndNil(Buffer);
Free;
stream.Free;
end;
end;