diff --git a/src/extension/internal/png-output.cpp b/src/extension/internal/png-output.cpp index 06ac7506229ee41d9354deb9a729d6df43aa8830..869e5484cdeb9108ce976077d6cf8e44ced204ab 100644 --- a/src/extension/internal/png-output.cpp +++ b/src/extension/internal/png-output.cpp @@ -14,19 +14,14 @@ #include "png-output.h" -#include -#include -#include -#include +#include #include #include +#include +#include #include "clear-n_.h" -// Replace with C++17, see notes in file-export-cmd.cpp -#include -namespace filesystem = boost::filesystem; - namespace Inkscape { namespace Extension { namespace Internal { @@ -35,10 +30,18 @@ void PngOutput::export_raster(Inkscape::Extension::Output * /*module*/, const SPDocument * /*doc*/, std::string const &png_file, gchar const *filename) { // We want to move the png file to the new location - auto input_fn = filesystem::path(png_file); - auto output_fn = filesystem::path(filename); - filesystem::copy_file(input_fn, output_fn, filesystem::copy_option::overwrite_if_exists); - boost::filesystem::remove(input_fn); + Glib::RefPtr input_fn = Gio::File::create_for_path(png_file); + Glib::RefPtr output_fn = Gio::File::create_for_path(filename); + try { + // NOTE: if the underlying filesystem doesn't support moving + // GIO will fall back to a copy and remove operation. + input_fn->move(output_fn, Gio::FILE_COPY_OVERWRITE); + } + catch (const Gio::Error& e) { + std::cerr << "Moving resource " << png_file + << " to " << filename + << " failed: " << e.what() << std::endl; + } } void PngOutput::init() diff --git a/src/io/file-export-cmd.cpp b/src/io/file-export-cmd.cpp index 15c31ee47a373a903dff7102e621f1b322a28ed2..cdedbb05a0a5b3577a83f94599bf0e981a80d91d 100644 --- a/src/io/file-export-cmd.cpp +++ b/src/io/file-export-cmd.cpp @@ -43,8 +43,13 @@ // C++17 std::filesystem (with #include ) then we drop this dep // (Dev meeting, 2020-09-25) +#ifdef G_OS_WIN32 +#include +namespace filesystem = std::filesystem; +#else #include namespace filesystem = boost::filesystem; +#endif InkFileExportCmd::InkFileExportCmd() : export_overwrite(false) @@ -75,7 +80,11 @@ InkFileExportCmd::do_export(SPDocument* doc, std::string filename_in) // Get export type from filename supplied with --export-filename if (!export_filename.empty() && export_filename != "-") { +#ifdef G_OS_WIN32 + auto fn = filesystem::u8path(export_filename); +#else auto fn = filesystem::path(export_filename); +#endif if (!fn.has_extension()) { if (export_type.empty() && export_extension.empty()) { std::cerr << "InkFileExportCmd::do_export: No export type specified. " diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 15eab81993180bd32b2aac9f54d29ff29ec417d5..bd045589dfd9364e9bc8b713a928fd0ffdef453a 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -4,9 +4,16 @@ #include #include +#ifdef G_OS_WIN32 +#include +using fs = std::filesystem; +using fs_path = fs::u8path; +#else +// Waiting for compiler on MacOS to catch up to C++x17 #include -namespace filesystem = boost::filesystem; -// #include - waiting for compiler on MacOS to catch up to C++x17 +using fs = boost::filesystem; +using fs_path = fs::path; +#endif #include "io/resource.h" #include "inkscape-application.h" @@ -241,7 +248,7 @@ void DialogManager::restore_dialogs_state(DialogContainer *docking_container, bo try { auto keyfile = std::make_unique(); std::string filename = Glib::build_filename(Inkscape::IO::Resource::profile_path(), dialogs_state); - if (filesystem::exists(filename) && keyfile->load_from_file(filename)) { + if (fs::exists(fs_path(filename)) && keyfile->load_from_file(filename)) { // restore visible dialogs first; that state is up-to-date docking_container->load_container_state(keyfile.get(), include_floating);