Skip to content

Commit

Permalink
Fix building untwine on MinGW-w64
Browse files Browse the repository at this point in the history
  • Loading branch information
MehdiChinoune authored and nyalldawson committed Nov 8, 2024
1 parent 8604948 commit 43b4b54
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
40 changes: 39 additions & 1 deletion external/untwine/untwine/mingw/dirlist.hpp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#pragma once

#include <windows.h>
#include <io.h>
#include <fcntl.h>

#include <stringconv.hpp>

namespace untwine
{
Expand Down Expand Up @@ -30,7 +34,7 @@ struct MapContext
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;

Expand Down Expand Up @@ -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.";
Expand Down

0 comments on commit 43b4b54

Please sign in to comment.