Caio Oliveira
4 weeks ago
No known key found for this signature in database
GPG Key ID: AAAE6C7FD4186B0C
2 changed files with
6 additions and
6 deletions
-
src/common/fs/file.cpp
-
src/common/fs/file.h
|
|
@ -530,13 +530,13 @@ bool IOFile::Seek(s64 offset, SeekOrigin origin) const { |
|
|
// fuck you to whoever made this method const
|
|
|
// fuck you to whoever made this method const
|
|
|
switch (origin) { |
|
|
switch (origin) { |
|
|
case SeekOrigin::SetOrigin: |
|
|
case SeekOrigin::SetOrigin: |
|
|
mmap_offset = off_t(offset); |
|
|
|
|
|
|
|
|
mmap_offset = s64(offset); |
|
|
break; |
|
|
break; |
|
|
case SeekOrigin::CurrentPosition: |
|
|
case SeekOrigin::CurrentPosition: |
|
|
mmap_offset += off_t(offset); |
|
|
|
|
|
|
|
|
mmap_offset += s64(offset); |
|
|
break; |
|
|
break; |
|
|
case SeekOrigin::End: |
|
|
case SeekOrigin::End: |
|
|
mmap_offset = off_t(mmap_size) + off_t(offset); |
|
|
|
|
|
|
|
|
mmap_offset = s64(mmap_size) + s64(offset); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
|
|
|
@ -323,7 +323,7 @@ public: |
|
|
if (IsMappedFile()) { |
|
|
if (IsMappedFile()) { |
|
|
std::memcpy(&object, mmap_base + mmap_offset, sizeof(T)); |
|
|
std::memcpy(&object, mmap_base + mmap_offset, sizeof(T)); |
|
|
#ifdef _WIN32 |
|
|
#ifdef _WIN32 |
|
|
return sizeof(T) != 0; |
|
|
|
|
|
|
|
|
return bool(sizeof(T)); |
|
|
#else |
|
|
#else |
|
|
return sizeof(T); |
|
|
return sizeof(T); |
|
|
#endif |
|
|
#endif |
|
|
@ -442,7 +442,7 @@ public: |
|
|
[[nodiscard]] s64 Tell() const; |
|
|
[[nodiscard]] s64 Tell() const; |
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
#ifdef _WIN32 |
|
|
inline bool IsMappedFile() const noexcept { return file_handle != nullptr; } |
|
|
|
|
|
|
|
|
inline bool IsMappedFile() const noexcept { return mapping_handle != nullptr; } |
|
|
#else // POSIX |
|
|
#else // POSIX |
|
|
inline bool IsMappedFile() const noexcept { return mmap_fd != -1; } |
|
|
inline bool IsMappedFile() const noexcept { return mmap_fd != -1; } |
|
|
#endif |
|
|
#endif |
|
|
@ -462,7 +462,7 @@ public: |
|
|
#endif |
|
|
#endif |
|
|
u8* mmap_base = nullptr; |
|
|
u8* mmap_base = nullptr; |
|
|
size_t mmap_size = 0; |
|
|
size_t mmap_size = 0; |
|
|
mutable off_t mmap_offset = 0; // fuck you |
|
|
|
|
|
|
|
|
mutable s64 mmap_offset = 0; // fuck you |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
} // namespace Common::FS |
|
|
} // namespace Common::FS |