diff options
| author | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
|---|---|---|
| committer | SulfurNitride <SulfurNitride@users.noreply.github.com> | 2026-02-11 02:37:39 -0600 |
| commit | 7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch) | |
| tree | 27fb39be241fdb5ac2734c574de678977d1856d0 /libs/esptk/src/subrecord.cpp | |
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem,
Proton/umu-run integration, and Flatpak packaging.
Key features:
- FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak)
- Proton/GE-Proton/umu-run launcher with env var forwarding
- Flatpak support (sandbox-aware VFS, NXM handler, umu-run)
- Wine prefix management UI
- Case-insensitive path resolution for Linux filesystems
- QSettings-safe INI handling (avoids Bethesda INI corruption)
- Portable instance support with auto-generated launcher scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/esptk/src/subrecord.cpp')
| -rw-r--r-- | libs/esptk/src/subrecord.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libs/esptk/src/subrecord.cpp b/libs/esptk/src/subrecord.cpp new file mode 100644 index 0000000..cb3890a --- /dev/null +++ b/libs/esptk/src/subrecord.cpp @@ -0,0 +1,59 @@ +#include "subrecord.h" +#include "espexceptions.h" +#include "esptypes.h" +#include <cstdint> +#include <cstring> +#include <string> +#include <unordered_map> + +ESP::SubRecord::SubRecord() : m_Type(TYPE_UNKNOWN), m_Data() {} + +bool ESP::SubRecord::readFrom(std::istream& stream, uint32_t sizeOverride) +{ + static std::unordered_map<std::string, EType> s_TypeMap{{"HEDR", TYPE_HEDR}, + {"CNAM", TYPE_CNAM}, + {"MAST", TYPE_MAST}, + {"ONAM", TYPE_ONAM}, + {"SNAM", TYPE_SNAM}}; + + char typeString[5]; + if (!stream.read(typeString, 4)) { + if (stream.gcount() == 0) { + return false; + } else { + throw ESP::InvalidRecordException("sub-record incomplete (unknown type)"); + } + } + if (stream.gcount() != 4) { + throw ESP::InvalidRecordException( + std::string("sub-record type incomplete (invalid type ") + typeString + ")"); + } + typeString[4] = '\0'; // not sure if this is required, shouldn't be + auto iter = s_TypeMap.find(std::string(typeString)); + if (iter != s_TypeMap.end()) { + m_Type = iter->second; + } else if (strncmp(typeString, "XXXX", 4) == 0) { + if (readType<uint16_t>(stream) != 4) { + throw ESP::InvalidRecordException( + "XXXX record is supposed to be 4 bytes in size"); + } + return readFrom(stream, readType<uint32_t>(stream)); + } else { + m_Type = TYPE_UNKNOWN; + } + + uint32_t dataSize = readType<uint16_t>(stream); + if (sizeOverride != 0UL) { + dataSize = sizeOverride; + } + m_Data.resize(dataSize); + + if (dataSize > 0) { + stream.read(reinterpret_cast<char*>(m_Data.data()), dataSize); + } + if (!stream) { + throw ESP::InvalidRecordException(std::string("sub-record incomplete: ") + + typeString); + } + return true; +} |
