Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.
Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
This commit is contained in:
parent
35d2a8cb36
commit
a47d20f8be
890 changed files with 11796 additions and 16664 deletions
|
|
@ -1,13 +1,10 @@
|
|||
#include "Archive/PakFile.h"
|
||||
|
||||
#include <bit>
|
||||
|
||||
// OFFSET: 0x005EF660
|
||||
// FUNCTION: fn_04009
|
||||
CPakFile::~CPakFile() = default;
|
||||
|
||||
namespace myGPack {
|
||||
|
||||
// OFFSET: 0x005F7790
|
||||
// FUNCTION: fn_04046
|
||||
CReadPakFile::CReadPakFile() : m_handle(INVALID_HANDLE_VALUE), m_size(0) {
|
||||
|
|
@ -31,7 +28,6 @@ namespace myGPack {
|
|||
// OFFSET: 0x005F7810
|
||||
// FUNCTION: fn_04047
|
||||
void CReadPakFile::Close() {
|
||||
// The original tests for null, not INVALID_HANDLE_VALUE.
|
||||
if (this->m_handle) {
|
||||
CloseHandle(this->m_handle);
|
||||
this->m_handle = nullptr;
|
||||
|
|
@ -41,18 +37,15 @@ namespace myGPack {
|
|||
// OFFSET: 0x005F7890
|
||||
// FUNCTION: fn_04048
|
||||
bool CWritePakFile::Open(const char* filename) {
|
||||
this->m_handle = CreateFileA(
|
||||
filename, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr
|
||||
);
|
||||
this->m_handle = CreateFileA(filename, GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (this->m_handle == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LARGE_INTEGER size;
|
||||
// The original does not check GetFileSizeEx's return value.
|
||||
|
||||
GetFileSizeEx(this->m_handle, &size);
|
||||
this->m_size = std::bit_cast<std::uint64_t>(size.QuadPart);
|
||||
this->m_size = static_cast<std::uint64_t>(size.QuadPart);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -66,14 +59,15 @@ namespace myGPack {
|
|||
this->m_buffer.resize(length);
|
||||
|
||||
LARGE_INTEGER position;
|
||||
position.QuadPart = std::bit_cast<std::int64_t>(offset);
|
||||
// Seeking errors are not checked before the original ReadFile call.
|
||||
position.QuadPart = static_cast<std::int64_t>(offset);
|
||||
|
||||
SetFilePointerEx(this->m_handle, position, nullptr, FILE_BEGIN);
|
||||
|
||||
DWORD read;
|
||||
if (ReadFile(this->m_handle, this->m_buffer.data(), length, &read, nullptr) && read == length) {
|
||||
return this->m_buffer.data();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +75,7 @@ namespace myGPack {
|
|||
// FUNCTION: fn_04050
|
||||
bool CWritePakFile::Write(std::uint64_t offset, const void* bytes, std::uint32_t length) {
|
||||
LARGE_INTEGER position;
|
||||
position.QuadPart = std::bit_cast<std::int64_t>(offset);
|
||||
position.QuadPart = static_cast<std::int64_t>(offset);
|
||||
SetFilePointerEx(this->m_handle, position, nullptr, FILE_BEGIN);
|
||||
|
||||
DWORD written;
|
||||
|
|
@ -93,7 +87,7 @@ namespace myGPack {
|
|||
if (this->m_size < end) {
|
||||
this->m_size = end;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue