mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-12 05:49:56 -04:00
fix: windows build was broken after refactoring
This commit is contained in:
parent
160afe38dd
commit
df6718512c
@ -24,6 +24,7 @@
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <iosfwd>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@ -75,4 +76,6 @@ void setup_default_locale();
|
||||
|
||||
std::string_view basename(std::string_view path);
|
||||
|
||||
void ensure_binary_mode(std::ostream& os);
|
||||
|
||||
} // namespace dwarfs
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include <folly/ExceptionString.h>
|
||||
#include <folly/ScopeGuard.h>
|
||||
#include <folly/portability/Fcntl.h>
|
||||
#include <folly/system/ThreadName.h>
|
||||
|
||||
#include <dwarfs/file_stat.h>
|
||||
|
@ -23,7 +23,9 @@
|
||||
#include <array>
|
||||
#include <charconv>
|
||||
#include <clocale>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#if __has_include(<utf8cpp/utf8.h>)
|
||||
#include <utf8cpp/utf8.h>
|
||||
@ -35,6 +37,8 @@
|
||||
|
||||
#include <folly/Conv.h>
|
||||
#include <folly/String.h>
|
||||
#include <folly/portability/Fcntl.h>
|
||||
#include <folly/portability/Windows.h>
|
||||
|
||||
#include <dwarfs/error.h>
|
||||
#include <dwarfs/options.h>
|
||||
@ -363,4 +367,14 @@ std::string_view basename(std::string_view path) {
|
||||
return path.substr(pos + 1);
|
||||
}
|
||||
|
||||
void ensure_binary_mode(std::ostream& os [[maybe_unused]]) {
|
||||
#ifdef _WIN32
|
||||
if (&os == &std::cout) {
|
||||
_setmode(_fileno(stdout), _O_BINARY);
|
||||
} else if (&os == &std::cerr) {
|
||||
_setmode(_fileno(stderr), _O_BINARY);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace dwarfs
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#if __has_include(<boost/process/v2/environment.hpp>)
|
||||
#define BOOST_PROCESS_VERSION 2
|
||||
#include <boost/process/v2/environment.hpp>
|
||||
@ -48,6 +48,7 @@
|
||||
#include <folly/Conv.h>
|
||||
#include <folly/String.h>
|
||||
#include <folly/experimental/symbolizer/SignalHandler.h>
|
||||
#include <folly/portability/Fcntl.h>
|
||||
|
||||
#ifndef DWARFS_FUSE_LOWLEVEL
|
||||
#define DWARFS_FUSE_LOWLEVEL 1
|
||||
@ -290,7 +291,7 @@ void checked_reply_err(LogProxy& log_, fuse_req_t req, T&& f) {
|
||||
#endif
|
||||
|
||||
void check_fusermount(dwarfs_userdata& userdata) {
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
static constexpr std::string_view const fusermount_name = "fusermount3";
|
||||
|
@ -296,11 +296,7 @@ int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
if (print_header) {
|
||||
if (auto hdr = filesystem_v2::header(mm, fsopts.image_offset)) {
|
||||
#ifdef _WIN32
|
||||
if (&iol.out == &std::cout) {
|
||||
::_setmode(::_fileno(stdout), _O_BINARY);
|
||||
}
|
||||
#endif
|
||||
ensure_binary_mode(iol.out);
|
||||
iol.out.write(reinterpret_cast<char const*>(hdr->data()), hdr->size());
|
||||
if (iol.out.bad() || iol.out.fail()) {
|
||||
LOG_ERROR << "error writing header";
|
||||
|
@ -1142,9 +1142,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
|
||||
os.emplace<std::unique_ptr<output_stream>>(std::move(stream));
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
::_setmode(::_fileno(stdout), _O_BINARY);
|
||||
#endif
|
||||
ensure_binary_mode(iol.out);
|
||||
}
|
||||
} else {
|
||||
os.emplace<std::ostringstream>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user