Skip to content

Commit df57799

Browse files
committed
im tryin to build on all platforms son
1 parent e74d438 commit df57799

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

view/sharedcache/core/MappedFile.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ std::optional<MappedFile> MappedFile::OpenFile(const std::string &path)
143143
return file;
144144
}
145145

146-
MMapStatus MappedFile::Map()
146+
MapStatus MappedFile::Map()
147147
{
148148
if (_mmap)
149-
return MMapStatus::Success;
149+
return MapStatus::Success;
150150

151151
HANDLE hMapping = CreateFileMapping(
152152
hFile, // file handle
@@ -159,7 +159,7 @@ MMapStatus MappedFile::Map()
159159
if (hMapping == NULL)
160160
{
161161
CloseHandle(hFile);
162-
return MMapStatus::Error;
162+
return MapStatus::Error;
163163
}
164164

165165
_mmap = static_cast<uint8_t*>(MapViewOfFile(
@@ -173,21 +173,21 @@ MMapStatus MappedFile::Map()
173173
{
174174
CloseHandle(hMapping);
175175
CloseHandle(hFile);
176-
return MMapStatus::Error;
176+
return MapStatus::Error;
177177
}
178178

179179
CloseHandle(hMapping);
180180
CloseHandle(hFile);
181181

182-
return MMapStatus::Success;
182+
return MapStatus::Success;
183183
}
184184

185-
MMapStatus MappedFile::Unmap()
185+
MapStatus MappedFile::Unmap()
186186
{
187187
if (_mmap)
188188
{
189189
UnmapViewOfFile(_mmap);
190190
}
191-
return MMapStatus::Success;
191+
return MapStatus::Success;
192192
}
193193
#endif

view/sharedcache/core/MappedFile.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,40 @@ struct MappedFile
3333
MappedFile& operator=(const MappedFile&) = delete;
3434

3535
MappedFile(MappedFile&& other) noexcept
36-
: _mmap(other._mmap), len(other.len), fd(other.fd) {
36+
: _mmap(other._mmap), len(other.len) {
37+
#ifdef _MSC_VER
38+
hFile = other.hFile;
39+
// Don't close the hFile in the move.
40+
other.hFile = nullptr;
41+
#else
42+
fd = other.fd;
3743
// Don't close the fd in the move.
3844
other.fd = nullptr;
45+
#endif
3946
other._mmap = nullptr;
4047
}
4148

4249
// I hate C++
4350
MappedFile& operator=(MappedFile&& other) noexcept {
4451
if (this != &other) {
4552
Unmap();
53+
#ifdef _MSC_VER
54+
if (hFile != nullptr) {
55+
CloseHandle(hFile);
56+
}
57+
hFile = other.hFile;
58+
// Don't close the hFile in the move.
59+
other.hFile = nullptr;
60+
#else
4661
if (fd != nullptr) {
4762
fclose(fd);
4863
}
49-
5064
fd = other.fd;
51-
len = other.len;
52-
_mmap = other._mmap;
53-
5465
// Don't close the fd in the move.
5566
other.fd = nullptr;
67+
#endif
68+
len = other.len;
69+
_mmap = other._mmap;
5670
other._mmap = nullptr;
5771
}
5872
return *this;

view/sharedcache/core/SharedCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "SharedCache.h"
22

33
#include <regex>
4-
#include <__filesystem/directory_iterator.h>
4+
#include <filesystem>
55

66
#include "MachO.h"
77
#include "SlideInfo.h"

0 commit comments

Comments
 (0)