mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-03 21:45:32 +02:00
Use experimental/ghc filesystem for meson builds
This commit is contained in:
parent
84c5662ef2
commit
c4ce877186
13 changed files with 5997 additions and 17 deletions
|
@ -94,7 +94,7 @@ $(DOWNLOADS)/sigcxx/Makefile: $(DOWNLOADS)/sigcxx/autogen.sh
|
|||
$(AUTOGEN) --enable-static=yes --enable-shared=no
|
||||
|
||||
$(DOWNLOADS)/sigcxx/autogen.sh:
|
||||
$(CLONE) $(GITLAB)/mkxp-z/libsigcplusplus $(DOWNLOADS)/sigcxx
|
||||
$(CLONE) $(GITLAB)/mkxp-z/libsigcplusplus -b libsigc++-2-10 $(DOWNLOADS)/sigcxx
|
||||
|
||||
# Pixman
|
||||
pixman: init_dirs libpng $(LIBDIR)/libpixman-1.a
|
||||
|
|
|
@ -118,7 +118,6 @@
|
|||
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 */; };
|
||||
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 */; };
|
||||
3B5A840D2569BE7C00BAF2E5 /* filesystemImplApple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
|
@ -506,7 +510,6 @@
|
|||
3BD2B6ED2565AEC0003DAD8A /* libiconv.tbd in Frameworks */,
|
||||
3BE08105256879FE0006849F /* libvorbisfile.a in Frameworks */,
|
||||
3BE0810E256879FE0006849F /* libSDL2_image.a in Frameworks */,
|
||||
3B426F29256B6C75009EA00F /* libsigc-3.0.a in Frameworks */,
|
||||
3BE0811A256879FE0006849F /* libfreetype.a in Frameworks */,
|
||||
3BE0811D256879FE0006849F /* libphysfs.a in Frameworks */,
|
||||
);
|
||||
|
@ -672,6 +675,7 @@
|
|||
3B10ED522568E95D00372D13 /* filesystem */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B426F6A256B8AC0009EA00F /* ghc */,
|
||||
3B10ED532568E95D00372D13 /* filesystem.h */,
|
||||
3B10ED542568E95D00372D13 /* filesystem.cpp */,
|
||||
3B5A840C2569BE7C00BAF2E5 /* filesystemImplApple.mm */,
|
||||
|
@ -719,6 +723,7 @@
|
|||
3B10ED6F2568E95D00372D13 /* display */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B10ED7E2568E95D00372D13 /* gl */,
|
||||
3B10ED702568E95D00372D13 /* tilemap.h */,
|
||||
3B10ED712568E95D00372D13 /* tilemap-common.h */,
|
||||
3B10ED722568E95D00372D13 /* windowvx.cpp */,
|
||||
|
@ -733,7 +738,6 @@
|
|||
3B10ED7B2568E95D00372D13 /* graphics.cpp */,
|
||||
3B10ED7C2568E95D00372D13 /* sprite.h */,
|
||||
3B10ED7D2568E95D00372D13 /* tilemapvx.cpp */,
|
||||
3B10ED7E2568E95D00372D13 /* gl */,
|
||||
3B10ED9A2568E95E00372D13 /* font.h */,
|
||||
3B10ED9B2568E95E00372D13 /* graphics.h */,
|
||||
3B10ED9C2568E95E00372D13 /* tilemap.cpp */,
|
||||
|
@ -821,6 +825,19 @@
|
|||
path = ../binding;
|
||||
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 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -925,7 +942,6 @@
|
|||
3BE081492568A5F60006849F /* libturbojpeg.a */,
|
||||
3BE080FF256879FE0006849F /* libphysfs.a */,
|
||||
3BE080E9256879FC0006849F /* libpixman-1.a */,
|
||||
3B426F28256B6C75009EA00F /* libsigc-3.0.a */,
|
||||
3BE080F4256879FD0006849F /* libruby.2.6-static.a */,
|
||||
3BE080F0256879FD0006849F /* libSDL2_image.a */,
|
||||
3BE080FA256879FE0006849F /* libSDL2_test.a */,
|
||||
|
@ -1443,7 +1459,7 @@
|
|||
"$(DEPENDENCY_SEARCH_PATH)/include",
|
||||
"$(DEPENDENCY_SEARCH_PATH)/lib/**",
|
||||
"$(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/ruby-$(MRI_VERSION)",
|
||||
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin",
|
||||
|
@ -1477,7 +1493,7 @@
|
|||
"$(DEPENDENCY_SEARCH_PATH)/include",
|
||||
"$(DEPENDENCY_SEARCH_PATH)/lib/**",
|
||||
"$(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/ruby-$(MRI_VERSION)",
|
||||
"$(DEPENDENCY_SEARCH_PATH)/include/ruby-$(MRI_VERSION)/$(BUILD_ARCH)-darwin",
|
||||
|
|
|
@ -121,6 +121,10 @@ if get_option('easypoke') == true and miniffi == true
|
|||
global_args += '-DEASY_POKE'
|
||||
endif
|
||||
|
||||
if get_option('cxx11_experimental') == true
|
||||
global_args += '-DUSE_EXPERIMENTAL_FILESYSTEM'
|
||||
endif
|
||||
|
||||
if not get_option('console')
|
||||
global_args += '-DNO_CONSOLE'
|
||||
endif
|
||||
|
|
|
@ -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('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('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)')
|
||||
|
|
|
@ -7,15 +7,22 @@
|
|||
|
||||
#include "filesystemImpl.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>
|
||||
|
||||
// https://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
|
||||
bool filesystemImpl::fileExists(const char *path) {
|
||||
struct stat buffer;
|
||||
return (stat (path, &buffer) == 0);
|
||||
fs::path stdPath(path);
|
||||
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
|
||||
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() {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// filesystemImplApple.m
|
||||
// filesystemImplApple.mm
|
||||
// Player
|
||||
//
|
||||
// Created by ゾロアーク on 11/21/20.
|
||||
|
|
5689
src/filesystem/ghc/filesystem.hpp
Normal file
5689
src/filesystem/ghc/filesystem.hpp
Normal file
File diff suppressed because it is too large
Load diff
38
src/filesystem/ghc/fs_fwd.hpp
Normal file
38
src/filesystem/ghc/fs_fwd.hpp
Normal 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
|
35
src/filesystem/ghc/fs_impl.hpp
Normal file
35
src/filesystem/ghc/fs_impl.hpp
Normal 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>
|
56
src/filesystem/ghc/fs_std.hpp
Normal file
56
src/filesystem/ghc/fs_std.hpp
Normal 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
|
||||
|
60
src/filesystem/ghc/fs_std_fwd.hpp
Normal file
60
src/filesystem/ghc/fs_std_fwd.hpp
Normal 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
|
||||
|
43
src/filesystem/ghc/fs_std_impl.hpp
Normal file
43
src/filesystem/ghc/fs_std_impl.hpp
Normal 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
|
|
@ -42,7 +42,7 @@ global_include_dirs += include_directories('.',
|
|||
'crypto',
|
||||
'display', 'display/gl',
|
||||
'etc',
|
||||
'filesystem',
|
||||
'filesystem', 'filesystem/ghc',
|
||||
'input',
|
||||
'system',
|
||||
'util'
|
||||
|
|
Loading…
Add table
Reference in a new issue