port 2D step 5a: EterPack/EterPackManager + EterBase file units against the real 40250 packs
- Mirror copies: EterPack (EterPack, EterPackManager, EterPackCursor, CSHybridCrypt policy, Inline.h) and EterBase logic units tea/lzo/Timer/Stl/Random, with PORT-tagged width fixes (LONG index fields, static_assert(sizeof(TEterPackIndex) == 192), tea_word = Win32 unsigned long). - TEA pack keys are extracted from the reference EterPack.cpp at configure time into build/.../EterPackKeys.generated.h; nothing key-bearing is tracked. - Platform EterBase: FileBase (stdio, case-insensitive fallback), MappedFile (mmap / MapViewOfFile), CRC32, Debug, Utils StringPath/StringLowers. - Win32Crt: CreateDirectory/DeleteFile/_access/MAKEFOURCC; Win32MinMax.h min/max (force-included on MinGW, whose windows.h omits them in C++). - tests/port_eterpack_test: registers pack/Index like PackInitialize and checks 119 registrations / 103 packs + root / 54891 entries / 52609 paths / 2282 overrides with first-registered-wins, and that exactly the 4 short-layout SECURITY files fail to load. - 2R count corrected (136 -> 119 registrations, 103 distinct packs + root). Not runtime-reachable yet (asset_io pack backend is step 5b), so port-map statuses stay TODO. port_gate: macos/android/ios/windows PASS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include <new>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static_assert(sizeof(std::recursive_mutex) <= sizeof(CRITICAL_SECTION::storage), "CRITICAL_SECTION storage");
|
||||
static_assert(alignof(std::recursive_mutex) <= 16, "CRITICAL_SECTION alignment");
|
||||
|
||||
@@ -21,6 +24,26 @@ void DeleteCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).~recursive_mute
|
||||
void EnterCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).lock(); }
|
||||
void LeaveCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).unlock(); }
|
||||
|
||||
BOOL CreateDirectory(LPCSTR path, void*)
|
||||
{
|
||||
return mkdir(path, 0777) == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
BOOL DeleteFile(LPCSTR path)
|
||||
{
|
||||
return unlink(path) == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
int _access(const char* path, int mode)
|
||||
{
|
||||
int m = F_OK;
|
||||
if (mode & 2)
|
||||
m |= W_OK;
|
||||
if (mode & 4)
|
||||
m |= R_OK;
|
||||
return access(path, m);
|
||||
}
|
||||
|
||||
char* _strlwr(char* s)
|
||||
{
|
||||
for (char* p = s; *p; ++p)
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
|
||||
#include "Win32MinMax.h"
|
||||
|
||||
// mmsystem.h
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
|
||||
#endif
|
||||
|
||||
#define ZeroMemory(dst, len) std::memset((dst), 0, (len))
|
||||
#define FillMemory(dst, len, fill) std::memset((dst), (fill), (len))
|
||||
#define CopyMemory(dst, src, len) std::memcpy((dst), (src), (len))
|
||||
@@ -41,6 +49,12 @@ int _snprintf(char* buf, size_t count, const char* fmt, ...)
|
||||
#endif
|
||||
;
|
||||
|
||||
// kernel32 file-system calls (ANSI). CreateDirectory ignores the security attributes; _access takes
|
||||
// the MSVC modes 0 (exists), 2 (write), 4 (read), 6 (read/write).
|
||||
BOOL CreateDirectory(LPCSTR path, void* security_attributes);
|
||||
BOOL DeleteFile(LPCSTR path);
|
||||
int _access(const char* path, int mode);
|
||||
|
||||
// winmm `timeGetTime`: milliseconds since system start, wrapping at 2^32.
|
||||
DWORD timeGetTime();
|
||||
DWORD GetTickCount();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
// windef.h `min`/`max` macros (40250 builds without NOMINMAX), as functions so <algorithm> and
|
||||
// numeric_limits<T>::max() keep working: same usual-arithmetic-conversion result as the macro, and a
|
||||
// same-typed call under `using namespace std` still resolves to the more specialized std::min/max.
|
||||
// Included by Win32Crt.h off Windows, and force-included on MinGW, whose <windows.h> leaves them out in C++.
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(min) && !defined(max)
|
||||
template <class A, class B>
|
||||
constexpr std::common_type_t<A, B> min(A a, B b) { return (a < b) ? a : b; }
|
||||
template <class A, class B>
|
||||
constexpr std::common_type_t<A, B> max(A a, B b) { return (a > b) ? a : b; }
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
// Shim for 40250's <cryptopp/cryptoppLibLink.h>, which only holds MSVC `#pragma comment(lib, ...)` auto-link
|
||||
// lines; the vendored Crypto++ (mt3p::cryptopp) is linked by CMake.
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
// Shim for 40250's <lzo/lzoLibLink.h>, which only holds MSVC `#pragma comment(lib, ...)` auto-link lines;
|
||||
// the vendored minilzo (mt3p::minilzo) is linked by CMake.
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
// Shim for <io.h> on non-Windows targets; what 40250 logic uses from it (_access) is in <windows.h>.
|
||||
#include "windows.h"
|
||||
Reference in New Issue
Block a user