Use experimental/ghc filesystem for meson builds

This commit is contained in:
Struma 2020-11-23 02:25:02 -05:00 committed by ゾロアーク
parent 84c5662ef2
commit c4ce877186
13 changed files with 5997 additions and 17 deletions

View file

@ -94,7 +94,7 @@ $(DOWNLOADS)/sigcxx/Makefile: $(DOWNLOADS)/sigcxx/autogen.sh
$(AUTOGEN) --enable-static=yes --enable-shared=no $(AUTOGEN) --enable-static=yes --enable-shared=no
$(DOWNLOADS)/sigcxx/autogen.sh: $(DOWNLOADS)/sigcxx/autogen.sh:
$(CLONE) $(GITLAB)/mkxp-z/libsigcplusplus $(DOWNLOADS)/sigcxx $(CLONE) $(GITLAB)/mkxp-z/libsigcplusplus -b libsigc++-2-10 $(DOWNLOADS)/sigcxx
# Pixman # Pixman
pixman: init_dirs libpng $(LIBDIR)/libpixman-1.a pixman: init_dirs libpng $(LIBDIR)/libpixman-1.a

View file

@ -118,7 +118,6 @@
3B10EE092568E96A00372D13 /* binding-mri.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF02568E96A00372D13 /* binding-mri.cpp */; }; 3B10EE092568E96A00372D13 /* binding-mri.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF02568E96A00372D13 /* binding-mri.cpp */; };
3B10EE0B2568E96A00372D13 /* module_rpg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF32568E96A00372D13 /* module_rpg.cpp */; }; 3B10EE0B2568E96A00372D13 /* module_rpg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF32568E96A00372D13 /* module_rpg.cpp */; };
3B10EE0C2568E96A00372D13 /* viewport-binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF42568E96A00372D13 /* viewport-binding.cpp */; }; 3B10EE0C2568E96A00372D13 /* viewport-binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B10EDF42568E96A00372D13 /* viewport-binding.cpp */; };
3B426F29256B6C75009EA00F /* libsigc-3.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B426F28256B6C75009EA00F /* libsigc-3.0.a */; };
3B5A84062569B56F00BAF2E5 /* config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A84052569B56F00BAF2E5 /* config.cpp */; }; 3B5A84062569B56F00BAF2E5 /* config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A84052569B56F00BAF2E5 /* config.cpp */; };
3B5A840D2569BE7C00BAF2E5 /* filesystemImplApple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */; }; 3B5A840D2569BE7C00BAF2E5 /* filesystemImplApple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */; };
3B5A84342569F82C00BAF2E5 /* mkxp.json in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3BD2B7282565B35D003DAD8A /* mkxp.json */; }; 3B5A84342569F82C00BAF2E5 /* mkxp.json in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3BD2B7282565B35D003DAD8A /* mkxp.json */; };
@ -412,7 +411,12 @@
3B10EDF32568E96A00372D13 /* module_rpg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = module_rpg.cpp; sourceTree = "<group>"; }; 3B10EDF32568E96A00372D13 /* module_rpg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = module_rpg.cpp; sourceTree = "<group>"; };
3B10EDF42568E96A00372D13 /* viewport-binding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "viewport-binding.cpp"; sourceTree = "<group>"; }; 3B10EDF42568E96A00372D13 /* viewport-binding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "viewport-binding.cpp"; sourceTree = "<group>"; };
3B10EE1F2569348E00372D13 /* json5pp.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = json5pp.hpp; sourceTree = "<group>"; }; 3B10EE1F2569348E00372D13 /* json5pp.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = json5pp.hpp; sourceTree = "<group>"; };
3B426F28256B6C75009EA00F /* libsigc-3.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libsigc-3.0.a"; path = "Dependencies/build-macosx-x86_64/lib/libsigc-3.0.a"; sourceTree = "<group>"; }; 3B426F6B256B8AC0009EA00F /* fs_std_impl.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fs_std_impl.hpp; sourceTree = "<group>"; };
3B426F6C256B8AC0009EA00F /* fs_fwd.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fs_fwd.hpp; sourceTree = "<group>"; };
3B426F6D256B8AC0009EA00F /* fs_std.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fs_std.hpp; sourceTree = "<group>"; };
3B426F6E256B8AC0009EA00F /* filesystem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = filesystem.hpp; sourceTree = "<group>"; };
3B426F6F256B8AC0009EA00F /* fs_impl.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fs_impl.hpp; sourceTree = "<group>"; };
3B426F70256B8AC0009EA00F /* fs_std_fwd.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fs_std_fwd.hpp; sourceTree = "<group>"; };
3B5A84052569B56F00BAF2E5 /* config.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = config.cpp; sourceTree = "<group>"; }; 3B5A84052569B56F00BAF2E5 /* config.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = config.cpp; sourceTree = "<group>"; };
3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = filesystemImplApple.mm; sourceTree = "<group>"; }; 3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = filesystemImplApple.mm; sourceTree = "<group>"; };
3B5A84132569C28B00BAF2E5 /* filesystemImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = filesystemImpl.cpp; sourceTree = "<group>"; }; 3B5A84132569C28B00BAF2E5 /* filesystemImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = filesystemImpl.cpp; sourceTree = "<group>"; };
@ -506,7 +510,6 @@
3BD2B6ED2565AEC0003DAD8A /* libiconv.tbd in Frameworks */, 3BD2B6ED2565AEC0003DAD8A /* libiconv.tbd in Frameworks */,
3BE08105256879FE0006849F /* libvorbisfile.a in Frameworks */, 3BE08105256879FE0006849F /* libvorbisfile.a in Frameworks */,
3BE0810E256879FE0006849F /* libSDL2_image.a in Frameworks */, 3BE0810E256879FE0006849F /* libSDL2_image.a in Frameworks */,
3B426F29256B6C75009EA00F /* libsigc-3.0.a in Frameworks */,
3BE0811A256879FE0006849F /* libfreetype.a in Frameworks */, 3BE0811A256879FE0006849F /* libfreetype.a in Frameworks */,
3BE0811D256879FE0006849F /* libphysfs.a in Frameworks */, 3BE0811D256879FE0006849F /* libphysfs.a in Frameworks */,
); );
@ -672,6 +675,7 @@
3B10ED522568E95D00372D13 /* filesystem */ = { 3B10ED522568E95D00372D13 /* filesystem */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3B426F6A256B8AC0009EA00F /* ghc */,
3B10ED532568E95D00372D13 /* filesystem.h */, 3B10ED532568E95D00372D13 /* filesystem.h */,
3B10ED542568E95D00372D13 /* filesystem.cpp */, 3B10ED542568E95D00372D13 /* filesystem.cpp */,
3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */, 3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */,
@ -719,6 +723,7 @@
3B10ED6F2568E95D00372D13 /* display */ = { 3B10ED6F2568E95D00372D13 /* display */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3B10ED7E2568E95D00372D13 /* gl */,
3B10ED702568E95D00372D13 /* tilemap.h */, 3B10ED702568E95D00372D13 /* tilemap.h */,
3B10ED712568E95D00372D13 /* tilemap-common.h */, 3B10ED712568E95D00372D13 /* tilemap-common.h */,
3B10ED722568E95D00372D13 /* windowvx.cpp */, 3B10ED722568E95D00372D13 /* windowvx.cpp */,
@ -733,7 +738,6 @@
3B10ED7B2568E95D00372D13 /* graphics.cpp */, 3B10ED7B2568E95D00372D13 /* graphics.cpp */,
3B10ED7C2568E95D00372D13 /* sprite.h */, 3B10ED7C2568E95D00372D13 /* sprite.h */,
3B10ED7D2568E95D00372D13 /* tilemapvx.cpp */, 3B10ED7D2568E95D00372D13 /* tilemapvx.cpp */,
3B10ED7E2568E95D00372D13 /* gl */,
3B10ED9A2568E95E00372D13 /* font.h */, 3B10ED9A2568E95E00372D13 /* font.h */,
3B10ED9B2568E95E00372D13 /* graphics.h */, 3B10ED9B2568E95E00372D13 /* graphics.h */,
3B10ED9C2568E95E00372D13 /* tilemap.cpp */, 3B10ED9C2568E95E00372D13 /* tilemap.cpp */,
@ -821,6 +825,19 @@
path = ../binding; path = ../binding;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
3B426F6A256B8AC0009EA00F /* ghc */ = {
isa = PBXGroup;
children = (
3B426F6B256B8AC0009EA00F /* fs_std_impl.hpp */,
3B426F6C256B8AC0009EA00F /* fs_fwd.hpp */,
3B426F6D256B8AC0009EA00F /* fs_std.hpp */,
3B426F6E256B8AC0009EA00F /* filesystem.hpp */,
3B426F6F256B8AC0009EA00F /* fs_impl.hpp */,
3B426F70256B8AC0009EA00F /* fs_std_fwd.hpp */,
);
path = ghc;
sourceTree = "<group>";
};
3BA08EA5256641ED00449CFF /* misc */ = { 3BA08EA5256641ED00449CFF /* misc */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -925,7 +942,6 @@
3BE081492568A5F60006849F /* libturbojpeg.a */, 3BE081492568A5F60006849F /* libturbojpeg.a */,
3BE080FF256879FE0006849F /* libphysfs.a */, 3BE080FF256879FE0006849F /* libphysfs.a */,
3BE080E9256879FC0006849F /* libpixman-1.a */, 3BE080E9256879FC0006849F /* libpixman-1.a */,
3B426F28256B6C75009EA00F /* libsigc-3.0.a */,
3BE080F4256879FD0006849F /* libruby.2.6-static.a */, 3BE080F4256879FD0006849F /* libruby.2.6-static.a */,
3BE080F0256879FD0006849F /* libSDL2_image.a */, 3BE080F0256879FD0006849F /* libSDL2_image.a */,
3BE080FA256879FE0006849F /* libSDL2_test.a */, 3BE080FA256879FE0006849F /* libSDL2_test.a */,
@ -1443,7 +1459,7 @@
"$(DEPENDENCY_SEARCH_PATH)/include", "$(DEPENDENCY_SEARCH_PATH)/include",
"$(DEPENDENCY_SEARCH_PATH)/lib/**", "$(DEPENDENCY_SEARCH_PATH)/lib/**",
"$(DEPENDENCY_SEARCH_PATH)/include/SDL2", "$(DEPENDENCY_SEARCH_PATH)/include/SDL2",
"$(DEPENDENCY_SEARCH_PATH)/include/sigc++-3.0", "$(DEPENDENCY_SEARCH_PATH)/include/sigc++-2.0",
"$(DEPENDENCY_SEARCH_PATH)/include/pixman-1", "$(DEPENDENCY_SEARCH_PATH)/include/pixman-1",
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)", "$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)",
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin", "$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin",
@ -1477,7 +1493,7 @@
"$(DEPENDENCY_SEARCH_PATH)/include", "$(DEPENDENCY_SEARCH_PATH)/include",
"$(DEPENDENCY_SEARCH_PATH)/lib/**", "$(DEPENDENCY_SEARCH_PATH)/lib/**",
"$(DEPENDENCY_SEARCH_PATH)/include/SDL2", "$(DEPENDENCY_SEARCH_PATH)/include/SDL2",
"$(DEPENDENCY_SEARCH_PATH)/include/sigc++-3.0", "$(DEPENDENCY_SEARCH_PATH)/include/sigc++-2.0",
"$(DEPENDENCY_SEARCH_PATH)/include/pixman-1", "$(DEPENDENCY_SEARCH_PATH)/include/pixman-1",
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)", "$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)",
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin", "$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin",

View file

@ -121,6 +121,10 @@ if get_option('easypoke') == true and miniffi == true
global_args += '-DEASY_POKE' global_args += '-DEASY_POKE'
endif endif
if get_option('cxx11_experimental') == true
global_args += '-DUSE_EXPERIMENTAL_FILESYSTEM'
endif
if not get_option('console') if not get_option('console')
global_args += '-DNO_CONSOLE' global_args += '-DNO_CONSOLE'
endif endif

View file

@ -7,6 +7,7 @@ option('console', type: 'boolean', value: false, description: 'Whether to debug
option('macos_min_version', type: 'string', value: '', description: 'Minimum macOS system version to support (does not affect dependencies)') option('macos_min_version', type: 'string', value: '', description: 'Minimum macOS system version to support (does not affect dependencies)')
option('force32', type: 'boolean', value: false, description: 'Force compiler to build a 32-bit executable') option('force32', type: 'boolean', value: false, description: 'Force compiler to build a 32-bit executable')
option('cxx11_experimental', type: 'boolean', value: false, description: 'Toggles between using ghc/filesystem or C++11 <experimental/filesystem>')
option('shared_fluid', type: 'boolean', value: false, description: 'Dynamically link fluidsynth at build time') option('shared_fluid', type: 'boolean', value: false, description: 'Dynamically link fluidsynth at build time')
option('cjk_fallback_font', type: 'boolean', value: false, description: 'Use WenQuanYi Micro Hei as the fallback font') option('cjk_fallback_font', type: 'boolean', value: false, description: 'Use WenQuanYi Micro Hei as the fallback font')
option('use_miniffi', type: 'boolean', value: true, description: 'Enable MiniFFI Ruby module (Win32API)') option('use_miniffi', type: 'boolean', value: true, description: 'Enable MiniFFI Ruby module (Win32API)')

View file

@ -7,15 +7,22 @@
#include "filesystemImpl.h" #include "filesystemImpl.h"
#include "util/exception.h" #include "util/exception.h"
#include "util/debugwriter.h"
#ifdef USE_EXPERIMENTAL_FILESYSTEM
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#include "ghc/filesystem.hpp"
namespace fs = ghc::filesystem;
#endif
#include <sys/stat.h>
#include <unistd.h>
#include <fstream> #include <fstream>
// https://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c // https://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
bool filesystemImpl::fileExists(const char *path) { bool filesystemImpl::fileExists(const char *path) {
struct stat buffer; fs::path stdPath(path);
return (stat (path, &buffer) == 0); return (fs::exists(stdPath) && !fs::is_directory(stdPath));
} }
@ -35,14 +42,45 @@ std::string filesystemImpl::contentsOfFileAsString(const char *path) {
// chdir and getcwd do not support unicode on Windows // chdir and getcwd do not support unicode on Windows
bool filesystemImpl::setCurrentDirectory(const char *path) { bool filesystemImpl::setCurrentDirectory(const char *path) {
return chdir(path); fs::path stdPath(path);
fs::current_path(stdPath);
bool ret;
try {
ret = fs::equivalent(fs::current_path(), stdPath);
} catch (...) {
Debug() << "Failed to check current path." << path;
ret = false;
}
return ret;
} }
std::string filesystemImpl::getCurrentDirectory() { std::string filesystemImpl::getCurrentDirectory() {
return std::string(getcwd(0,0)); std::string ret;
try {
ret = std::string(fs::current_path().string());
} catch (...) {
throw new Exception(Exception::MKXPError, "Failed to retrieve current path");
}
return ret;
} }
std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool absolute) { std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool absolute) {
return std::string(path); fs::path stdPath(path);
if (!stdPath.is_absolute() && absolute)
stdPath = fs::current_path() / stdPath;
stdPath.lexically_normal();
std::string ret(stdPath);
#ifdef __WINDOWS__
if (!preferred) {
for (int i = 0; i < ret.length(); i++) {
if (ret[i] == '\\')
ret[i] = '/';
}
}
#endif
return ret;
} }

View file

@ -1,5 +1,5 @@
// //
// filesystemImplApple.m // filesystemImplApple.mm
// Player // Player
// //
// Created by ゾロアーク on 11/21/20. // Created by ゾロアーク on 11/21/20.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be include at any place, where ghc::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
#endif // GHC_FILESYSTEM_FWD_H

View file

@ -0,0 +1,35 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>

View file

@ -0,0 +1,56 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std.hpp - The dynamic switching header that includes std::filesystem if detected
// or ghc::filesystem if not, and makes the resulting API available in the
// namespace fs.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_H
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include <filesystem>
namespace fs {
using namespace std::filesystem;
using ifstream = std::ifstream;
using ofstream = std::ofstream;
using fstream = std::fstream;
}
#endif
#endif
#ifndef GHC_USE_STD_FS
#define GHC_WIN_WSTRING_STRING_TYPE
#include <ghc/filesystem.hpp>
namespace fs {
using namespace ghc::filesystem;
using ifstream = ghc::filesystem::ifstream;
using ofstream = ghc::filesystem::ofstream;
using fstream = ghc::filesystem::fstream;
}
#endif
#endif // GHC_FILESYSTEM_STD_H

View file

@ -0,0 +1,60 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem that uses std::filesystem if it detects it.
// This file can be include at any place, where fs::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_std_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_FWD_H
#define GHC_FILESYSTEM_STD_FWD_H
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include <filesystem>
namespace fs {
using namespace std::filesystem;
using ifstream = std::ifstream;
using ofstream = std::ofstream;
using fstream = std::fstream;
}
#endif
#endif
#ifndef GHC_USE_STD_FS
#define GHC_WIN_WSTRING_STRING_TYPE
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
namespace fs {
using namespace ghc::filesystem;
using ifstream = ghc::filesystem::ifstream;
using ofstream = ghc::filesystem::ofstream;
using fstream = ghc::filesystem::fstream;
}
#endif
#endif // GHC_FILESYSTEM_STD_FWD_H

View file

@ -0,0 +1,43 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem that does nothing if std::filesystem is detected.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#endif
#endif
#ifndef GHC_USE_STD_FS
#define GHC_WIN_WSTRING_STRING_TYPE
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>
#endif

View file

@ -42,7 +42,7 @@ global_include_dirs += include_directories('.',
'crypto', 'crypto',
'display', 'display/gl', 'display', 'display/gl',
'etc', 'etc',
'filesystem', 'filesystem', 'filesystem/ghc',
'input', 'input',
'system', 'system',
'util' 'util'