From b6ce75aca67737f4dd21512455bc15cd6ecb2732 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 23 Jul 2015 13:53:48 +1000 Subject: [PATCH] build: windows fixes --- io.hpp | 2 +- io_win32.cpp | 18 +++++++++--------- io_win32.hpp | 4 ++-- netpbm.cpp | 6 +++--- tools/noise.cpp | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/io.hpp b/io.hpp index 11860944..cfb4b2bf 100644 --- a/io.hpp +++ b/io.hpp @@ -68,7 +68,7 @@ namespace util { operator HANDLE (void) const; - HANDLE handle; + HANDLE fd; }; #endif diff --git a/io_win32.cpp b/io_win32.cpp index ae60efb1..da825e45 100644 --- a/io_win32.cpp +++ b/io_win32.cpp @@ -128,29 +128,29 @@ mapped_file::cend (void) const //----------------------------------------------------------------------------- -util::handle_ref::handle_ref (): - handle (INVALID_HANDLE_VALUE) +util::handle::handle(): + fd (INVALID_HANDLE_VALUE) { ; } -util::handle_ref::~handle_ref () +util::handle::~handle () { reset (INVALID_HANDLE_VALUE); } void -util::handle_ref::reset (HANDLE _handle) +util::handle::reset (HANDLE _handle) { - if (handle != INVALID_HANDLE_VALUE) - if (!CloseHandle (handle)) + if (fd != INVALID_HANDLE_VALUE) + if (!CloseHandle (fd)) win32_error::throw_code (); - handle = _handle; + fd = _handle; } -util::handle_ref::operator HANDLE (void) const +util::handle::operator HANDLE (void) const { - return handle; + return fd; } diff --git a/io_win32.hpp b/io_win32.hpp index 36f21e8d..cf9dc844 100644 --- a/io_win32.hpp +++ b/io_win32.hpp @@ -44,8 +44,8 @@ namespace util { const uint8_t* cend (void) const; private: - handle_ref m_file; - handle_ref m_mapping; + handle m_file; + handle m_mapping; std::unique_ptr m_data; size_t m_size; diff --git a/netpbm.cpp b/netpbm.cpp index b74e5434..d9971635 100644 --- a/netpbm.cpp +++ b/netpbm.cpp @@ -97,7 +97,7 @@ void util::pgm::write (const util::image::buffer &src, const boost::filesystem::path &path) { - std::ofstream dst (path.c_str ()); + std::ofstream dst (path.string ()); write (src.begin (), src.w, src.h, src.s, path); } @@ -110,7 +110,7 @@ util::pgm::write (const uint8_t *restrict pixels, size_t stride, const boost::filesystem::path &path) { - std::ofstream dst (path.c_str ()); + std::ofstream dst (path.string ()); write (pixels, width, height, stride, dst); } @@ -137,7 +137,7 @@ util::ppm::write (const uint8_t *restrict pixels, size_t stride, const boost::filesystem::path &path) { - std::ofstream dst (path.c_str ()); + std::ofstream dst (path.string ()); write (pixels, width, height, stride, dst); } diff --git a/tools/noise.cpp b/tools/noise.cpp index 6965a65c..fd1db97a 100644 --- a/tools/noise.cpp +++ b/tools/noise.cpp @@ -181,7 +181,7 @@ main (int argc, char **argv) #endif -#ifndef ENABLE_DEBUGGING +#if !defined(ENABLE_DEBUGGING) and !defined(PLATFORM_WIN32) if (isatty (fileno (stdout))) { std::cerr << "cowardly refusing to dump binary data to console\n"; return EXIT_FAILURE;