Fix building untwine on MinGW-w64

This commit is contained in:
مهدي شينون (Mehdi Chinoune) 2024-11-07 06:56:50 +01:00 committed by Nyall Dawson
parent 860494865e
commit 43b4b54336
2 changed files with 45 additions and 3 deletions

View File

@ -1 +1,39 @@
#include "../generic/dirlist.hpp"
#pragma once
#include <filesystem>
#include <stringconv.hpp>
namespace untwine
{
namespace os
{
// PDAL's directoryList had a bug, so we've imported a working
// version here so that we can still use older PDAL releases.
inline std::vector<std::string> directoryList(const std::string& dir)
{
namespace fs = std::filesystem;
std::vector<std::string> files;
try
{
fs::directory_iterator it(toNative(dir));
fs::directory_iterator end;
while (it != end)
{
files.push_back(fromNative(it->path().string()));
it++;
}
}
catch (fs::filesystem_error&)
{
files.clear();
}
return files;
}
} // namespace os
} // namespace untwine

View File

@ -1,6 +1,10 @@
#pragma once
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#include <stringconv.hpp>
namespace untwine
{
@ -30,7 +34,7 @@ public:
HANDLE m_handle;
};
MapContext mapFile(const std::string& filename, bool readOnly, size_t pos, size_t size)
inline MapContext mapFile(const std::string& filename, bool readOnly, size_t pos, size_t size)
{
MapContext ctx;
@ -61,7 +65,7 @@ MapContext mapFile(const std::string& filename, bool readOnly, size_t pos, size_
return ctx;
}
MapContext unmapFile(MapContext ctx)
inline MapContext unmapFile(MapContext ctx)
{
if (UnmapViewOfFile(ctx.m_addr) == 0)
ctx.m_error = "Couldn't unmap file.";