diff options
| author | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-04-12 17:55:56 -0500 |
|---|---|---|
| committer | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-04-12 17:55:56 -0500 |
| commit | 892070f3dec1dc690983fd862880e37e711c2516 (patch) | |
| tree | 423da9fca609a9239efbb6c74ab2e8657975c5a4 /libs/bsatk/include | |
| parent | a0355c9b897281d0bfea48bec9d490724ecabd96 (diff) | |
Add BSA in-memory extraction and nested preview support
bsatk:
- Archive::extractToMemory() extracts a file directly into a byte buffer
instead of a filesystem path, backed by a std::ostringstream sink.
- Archive::findFile() locates a file by relative path, case-insensitive
and separator-agnostic, walking the folder tree recursively.
- extractDirect/extractCompressed now take std::ostream& so both the
ofstream and ostringstream paths share the same implementation.
libbsarch: shim rewrite on Linux to map the Windows API surface onto
bsatk::Archive, enabling preview_bsa to open vanilla BSAs via the
same interface as other plugins.
preview_bsa: double-click on a file in the BSA tree now extracts the
bytes via extractToMemory() and hands them to IOrganizer::previewFileData
for nested preview rendering (e.g. NIF inside a BSA).
uibase + organizerproxy + organizercore: new IOrganizer::previewFileData
virtual that routes in-memory file bytes through the first registered
IPluginPreview matching the extension. Uses heap + WA_DeleteOnClose +
open() to avoid nested exec() softlock from mod info filetree ->
preview_bsa tree -> nif preview.
docker/build-inner.sh: stage preview_nif shaders into plugin_data/shaders
so ShaderManager can load them via IOrganizer::getPluginDataPath().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'libs/bsatk/include')
| -rw-r--r-- | libs/bsatk/include/bsatk/bsaarchive.h | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/bsatk/include/bsatk/bsaarchive.h b/libs/bsatk/include/bsatk/bsaarchive.h index cd15f64..915b9fb 100644 --- a/libs/bsatk/include/bsatk/bsaarchive.h +++ b/libs/bsatk/include/bsatk/bsaarchive.h @@ -112,6 +112,23 @@ public: * @return ERROR_NONE on success or an error code */ EErrorCode extract(File::Ptr file, const char* outputDirectory) const; + + /** + * extract a file from the archive directly into an in-memory buffer. + * @param file descriptor of the file to extract + * @param result output buffer; cleared and filled with uncompressed file data + * @return ERROR_NONE on success or an error code + */ + EErrorCode extractToMemory(File::Ptr file, + std::vector<unsigned char>& result) const; + + /** + * find a file in the archive by its relative path. + * @param path relative path inside the archive (separators may be / or \, + * matching is case-insensitive). + * @return the file descriptor, or nullptr if no such file exists. + */ + File::Ptr findFile(const std::string& path) const; /** * @return archive flags */ @@ -211,8 +228,8 @@ private: void getDX10Header(DirectX::DDS_HEADER_DXT10& DX10Header, File::Ptr file, DirectX::DDS_HEADER DDSHeader) const; - EErrorCode extractDirect(File::Ptr file, std::ofstream& outFile) const; - EErrorCode extractCompressed(File::Ptr file, std::ofstream& outFile) const; + EErrorCode extractDirect(File::Ptr file, std::ostream& outFile) const; + EErrorCode extractCompressed(File::Ptr file, std::ostream& outFile) const; void createFolders(const std::string& targetDirectory, Folder::Ptr folder); |
