aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--libs/bsatk/include/bsatk/bsatypes.h2
-rw-r--r--libs/bsatk/src/bsaarchive.cpp6
-rw-r--r--libs/bsatk/src/bsafile.cpp6
-rw-r--r--libs/bsatk/src/bsafolder.cpp18
-rw-r--r--src/src/vfs/mo2filesystem.cpp7
6 files changed, 21 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7d3451..38b5ec3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -228,7 +228,6 @@ add_subdirectory(libs/diagnose_basic)
add_subdirectory(libs/check_fnis)
add_subdirectory(libs/tool_inibakery)
add_subdirectory(libs/tool_inieditor)
-
if(BUILD_DOTNET_PLUGINS)
if(WIN32 AND MSVC)
add_subdirectory(libs/installer_fomod_csharp)
diff --git a/libs/bsatk/include/bsatk/bsatypes.h b/libs/bsatk/include/bsatk/bsatypes.h
index 27dbdf5..aef2508 100644
--- a/libs/bsatk/include/bsatk/bsatypes.h
+++ b/libs/bsatk/include/bsatk/bsatypes.h
@@ -45,7 +45,7 @@ typedef unsigned long long BSAHash;
typedef unsigned char BSAUChar;
typedef unsigned short BSAUShort;
typedef unsigned int BSAUInt;
-typedef unsigned long BSAULong;
+typedef uint32_t BSAULong;
typedef unsigned long long BSAHash;
#endif // WIN32
diff --git a/libs/bsatk/src/bsaarchive.cpp b/libs/bsatk/src/bsaarchive.cpp
index 4ae94a6..172a0b2 100644
--- a/libs/bsatk/src/bsaarchive.cpp
+++ b/libs/bsatk/src/bsaarchive.cpp
@@ -282,7 +282,7 @@ EErrorCode Archive::read(const char* fileName, bool testHashes)
// flat list of folders as they were stored in the archive
std::vector<Folder::Ptr> folders;
- for (unsigned long i = 0; i < header.folderCount; ++i) {
+ for (BSAUInt i = 0; i < header.folderCount; ++i) {
folders.push_back(m_RootFolder->addFolder(m_File, header.fileNameLength,
header.offset, header.type));
}
@@ -619,7 +619,7 @@ void Archive::getDX10Header(DirectX::DDS_HEADER_DXT10& DX10Header, File::Ptr fil
DX10Header.miscFlags2 = 0;
}
-static const unsigned long CHUNK_SIZE = 128 * 1024;
+static const BSAULong CHUNK_SIZE = 128 * 1024;
EErrorCode Archive::extractDirect(File::Ptr file, std::ofstream& outFile) const
{
@@ -683,7 +683,7 @@ EErrorCode Archive::extractDirect(File::Ptr file, std::ofstream& outFile) const
std::unique_ptr<char[]> inBuffer(new char[CHUNK_SIZE]);
try {
- unsigned long sizeLeft = file->m_FileSize;
+ BSAULong sizeLeft = file->m_FileSize;
while (sizeLeft > 0) {
int chunkSize = (std::min)(sizeLeft, CHUNK_SIZE);
diff --git a/libs/bsatk/src/bsafile.cpp b/libs/bsatk/src/bsafile.cpp
index 3179c63..c0cc266 100644
--- a/libs/bsatk/src/bsafile.cpp
+++ b/libs/bsatk/src/bsafile.cpp
@@ -42,7 +42,7 @@ bool ByOffset(const File::Ptr& LHS, const File::Ptr& RHS)
return LHS->getDataOffset() < RHS->getDataOffset();
}
-static const unsigned long CHUNK_SIZE = 128 * 1024;
+static const BSAULong CHUNK_SIZE = 128 * 1024;
File::File(std::fstream& file, Folder* folder)
: m_Folder(folder), m_New(false), m_FileSize(0), m_UncompressedFileSize(0),
@@ -107,7 +107,7 @@ EErrorCode File::writeData(fstream& sourceArchive, fstream& targetArchive) const
sourceArchive.seekg(m_DataOffset, fstream::beg);
try {
- unsigned long sizeLeft = m_FileSize;
+ BSAULong sizeLeft = m_FileSize;
while (sizeLeft > 0) {
int chunkSize = (std::min)(sizeLeft, CHUNK_SIZE);
sourceArchive.read(inBuffer.get(), chunkSize);
@@ -126,7 +126,7 @@ EErrorCode File::writeData(fstream& sourceArchive, fstream& targetArchive) const
}
sourceFile.seekg(0, fstream::end);
m_FileSize = static_cast<BSAULong>(sourceFile.tellg());
- unsigned long sizeLeft = m_FileSize;
+ BSAULong sizeLeft = m_FileSize;
sourceFile.seekg(0, fstream::beg);
while (sizeLeft > 0) {
int chunkSize = (std::min)(sizeLeft, CHUNK_SIZE);
diff --git a/libs/bsatk/src/bsafolder.cpp b/libs/bsatk/src/bsafolder.cpp
index 7cb5f88..f8ef9d6 100644
--- a/libs/bsatk/src/bsafolder.cpp
+++ b/libs/bsatk/src/bsafolder.cpp
@@ -35,7 +35,7 @@ Folder::Folder() : m_Parent(nullptr), m_Name()
{
m_NameHash = calculateBSAHash(m_Name);
m_FileCount = 0;
- m_Offset = ULONG_MAX;
+ m_Offset = UINT64_MAX;
}
Folder::Ptr Folder::readFolder(std::fstream& file, BSAUInt fileNamesLength,
@@ -43,20 +43,20 @@ Folder::Ptr Folder::readFolder(std::fstream& file, BSAUInt fileNamesLength,
{
Folder::Ptr result(new Folder());
result->m_NameHash = readType<BSAHash>(file);
- result->m_FileCount = readType<unsigned long>(file);
- result->m_Offset = readType<unsigned long>(file);
+ result->m_FileCount = readType<BSAUInt>(file);
+ result->m_Offset = readType<BSAUInt>(file);
std::streamoff pos = file.tellg();
file.seekg(result->m_Offset - fileNamesLength, fstream::beg);
result->m_Name = readBString(file);
- for (unsigned long i = 0UL; i < result->m_FileCount; ++i) {
+ for (BSAUInt i = 0; i < result->m_FileCount; ++i) {
result->m_Files.push_back(File::Ptr(new File(file, result.get())));
}
- if (static_cast<unsigned long>(file.tellg()) > endPos) {
- endPos = static_cast<BSAULong>(file.tellg());
+ if (static_cast<BSAUInt>(file.tellg()) > endPos) {
+ endPos = static_cast<BSAUInt>(file.tellg());
}
file.seekg(pos);
@@ -78,12 +78,12 @@ Folder::Ptr Folder::readFolderSE(std::fstream& file, BSAUInt fileNamesLength,
result->m_Name = readBString(file);
- for (unsigned long i = 0UL; i < result->m_FileCount; ++i) {
+ for (BSAUInt i = 0; i < result->m_FileCount; ++i) {
result->m_Files.push_back(File::Ptr(new File(file, result.get())));
}
- if (static_cast<unsigned long>(file.tellg()) > endPos) {
- endPos = static_cast<BSAULong>(file.tellg());
+ if (static_cast<BSAUInt>(file.tellg()) > endPos) {
+ endPos = static_cast<BSAUInt>(file.tellg());
}
file.seekg(pos);
diff --git a/src/src/vfs/mo2filesystem.cpp b/src/src/vfs/mo2filesystem.cpp
index 4d71444..35a0098 100644
--- a/src/src/vfs/mo2filesystem.cpp
+++ b/src/src/vfs/mo2filesystem.cpp
@@ -509,8 +509,10 @@ void updateFileNode(Mo2FsContext* ctx, const std::string& relative,
} // namespace
-void mo2_init(void* /*userdata*/, struct fuse_conn_info* conn)
+void mo2_init(void* userdata, struct fuse_conn_info* conn)
{
+ auto* ctx = static_cast<Mo2FsContext*>(userdata);
+
// Keep kernel page cache valid across open/close as long as mtime/size are
// unchanged. Mod files are immutable during a game session, so this avoids
// re-reading file data from userspace on every open().
@@ -904,6 +906,7 @@ void mo2_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi)
}
int fd = -1;
+
if (writable) {
const int openFlags = O_RDWR;
if (isBacking && ctx->backing_dir_fd >= 0) {
@@ -929,7 +932,7 @@ void mo2_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi)
ctx->open_files[fh] = std::move(of);
}
- fi->fh = fh;
+ fi->fh = fh;
fi->keep_cache = 1;
fuse_reply_open(req, fi);
}