BlizzardCore: SFile::FileExists and FileGetIsLocalAmount

Ports SFile::FileExists (0x424E50), SFile::FileGetIsLocalAmount
(0x4217E0) and the Mopaq helpers SFileGetFileDetails (0x460F00) and
SFileGetIsLocalAmount (0x461040). The older 0x421FC0 FileExists is
renamed FileExistsInArchives. Blizzard::Streaming::GetIsLocalAmount
(0x44F370) is declared only; BlpTest, DbcTest and MpqTest get stand-ins
so they link.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Saty
2026-09-27 05:02:09 +02:00
co-authored by Claude Opus 5.5
parent 2df85b1eb9
commit d02b135887
5 changed files with 76 additions and 3 deletions
+17 -2
View File
@@ -115,6 +115,12 @@ int32_t STORMAPI SFile::EnableDirectAccess(uint32_t flags) {
return 1;
}
// VERIFY: 94f59314 auto
// OFFSET: 0x004217E0
bool STORMAPI SFile::FileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total) {
return Blizzard::Mopaq::SFileGetIsLocalAmount(name, local, total);
}
// VERIFY: eb299239 auto
// OFFSET: 0x00421850
int32_t STORMAPI SFile::GetActualFileName(SFileImpl* file, char* buffer, uint32_t size) {
@@ -471,9 +477,9 @@ bool System_SFile2::OldFindFile(const char* name, char* path, uint32_t size, uin
return false;
}
// VERIFY: ad785843 auto
// VERIFY: cd537558 auto
// OFFSET: 0x00421FC0
int32_t STORMAPI SFile::FileExists(const char* name) {
int32_t STORMAPI SFile::FileExistsInArchives(const char* name) {
int32_t result = Blizzard::Mopaq::SFileFileExists(nullptr, name, 0, nullptr);
if (result) {
@@ -952,6 +958,15 @@ fail:
return 0;
}
// VERIFY: 663ae688 auto
// OFFSET: 0x00424E50
int32_t STORMAPI SFile::FileExists(const char* name) {
char path[260];
uint32_t type;
return System_SFile2::FindFile(name, path, sizeof(path), 0, &type, nullptr);
}
// VERIFY: 6dee9c33 manual
// OFFSET: 0x00424E80
int32_t STORMAPI SFile::ReadFile(SArchive* archive, const char* name, void** data, uint32_t* size, uint32_t extra, uint32_t flags, SOVERLAPPED* overlapped) {
+2 -1
View File
@@ -70,7 +70,8 @@ class SFile {
static int32_t STORMAPI EnableDirectAccess(uint32_t flags);
static int32_t STORMAPI FileExists(const char* name);
static int32_t STORMAPI FileExistsEx(const char* name, uint32_t flags);
static int32_t STORMAPI FileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total);
static int32_t STORMAPI FileExistsInArchives(const char* name);
static bool STORMAPI FileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total);
static int32_t STORMAPI FileIsLocal(const char* name, int32_t flags);
static int32_t STORMAPI FileIsLocal(SFileImpl* file, int32_t flags);
static int32_t STORMAPI GetActualFileName(SFileImpl* file, char* buffer, uint32_t size);
@@ -1553,6 +1553,60 @@ int32_t Blizzard::Mopaq::SFileFileExists(System_SFile::ARCHIVEREC* handle, const
return result;
}
// VERIFY: c8a17ac8 auto
// OFFSET: 0x00460F00
bool Blizzard::Mopaq::SFileGetFileDetails(System_SFile::ARCHIVEREC* handle, const char* name, System_SFile::ARCHIVEREC** archiveOut, int64_t* offset, uint32_t* size) {
Blizzard::Util::Digest<16> md5 = System_SFile::s_emptyMd5;
System_SFile::ARCHIVEREC* record = nullptr;
uint32_t blockIndex;
if (GetFileBlockEntry(handle, name, md5, 0, nullptr, &record, &blockIndex, nullptr, nullptr) != 1 || !archiveOut) {
return false;
}
System_SFile::BLOCKENTRY entry = record->GetBlockEntry(blockIndex);
if (offset) {
*offset = entry.m_offset;
}
if (size) {
*size = entry.m_compressedSize;
}
*archiveOut = record;
return true;
}
// VERIFY: eccb0185 auto
// OFFSET: 0x00461040
bool Blizzard::Mopaq::SFileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total) {
System_SFile::ARCHIVEREC* archive = nullptr;
int64_t offset;
uint32_t size;
bool result = Blizzard::Mopaq::SFileGetFileDetails(nullptr, name, &archive, &offset, &size);
if (result) {
const char* path = archive->m_name;
if (Blizzard::Streaming::IsStreamedFile(path)) {
local += Blizzard::Streaming::GetIsLocalAmount(path, offset, size, name);
} else {
local += size;
}
total += size;
if (archive) {
archive->RemoveInternalArchiveRef();
}
}
return result;
}
// VERIFY: 2e816731 manual
// OFFSET: 0x0042C680
void System_SFile::ARCHIVEREC::SetMD5Check(uint32_t index, bool enabled) {
@@ -248,6 +248,8 @@ namespace Mopaq {
bool SFileCloseArchive(System_SFile::ARCHIVEREC* handle);
bool SFileEnableDirectAccess(uint32_t enable);
int32_t SFileFileExists(System_SFile::ARCHIVEREC* handle, const char* name, uint32_t flags, System_SFile::ARCHIVEREC** archiveOut);
bool SFileGetFileDetails(System_SFile::ARCHIVEREC* handle, const char* name, System_SFile::ARCHIVEREC** archiveOut, int64_t* offset, uint32_t* size);
bool SFileGetIsLocalAmount(const char* name, int64_t& local, int64_t& total);
uint32_t SFileGetLastError();
bool SFileOpenArchive(const char* path, int32_t priority, uint32_t flags, System_SFile::ARCHIVEREC** result);
bool SFileOpenArchive(IOUnit* file, const char* name, int32_t priority, uint32_t flags, System_SFile::ARCHIVEREC** result);
@@ -11,6 +11,7 @@ extern bool s_streamingReady;
extern bool s_isStreamingTrial;
int32_t CheckFileRange(const char* path, int64_t offset, uint32_t count, const char* name, int32_t flags);
uint32_t GetIsLocalAmount(const char* path, int64_t offset, uint32_t size, const char* name);
bool IsStreamedFile(const char* path);
bool IsStreamingMode();
bool ScanDirectoryForManifest(const Blizzard::File::ProcessDirParms& parms);