Move #include <filesystem>
in its own file to be consistent with experimental support...
Use `fs::` instead of `std::filesystem`
This commit is contained in:
parent
994e9265fc
commit
aac47413a0
9 changed files with 66 additions and 35 deletions
|
@ -551,6 +551,7 @@ set(stratagus_generic_HDRS
|
|||
src/include/depend.h
|
||||
src/include/editor.h
|
||||
src/include/online_service.h
|
||||
src/include/filesystem.h
|
||||
src/include/font.h
|
||||
src/include/fov.h
|
||||
src/include/fow.h
|
||||
|
|
51
src/include/filesystem.h
Normal file
51
src/include/filesystem.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name filesystem - filesystem header selection. */
|
||||
//
|
||||
// (c) Copyright 1998-2023 by Lutz Sammer, Jimmy Salmon and Joris Dauphin.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef __FILESYSTEM_H__
|
||||
#define __FILESYSTEM_H__
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
# include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
# include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
error "Missing the <filesystem> header."
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
||||
#endif /* __FILESYSTEM_H__ */
|
|
@ -37,6 +37,7 @@
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include <vector>
|
||||
#include "filesystem.h"
|
||||
#include "SDL.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -47,6 +47,9 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "stratagus.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -32,15 +32,7 @@
|
|||
|
||||
//@{
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
error "Missing the <filesystem> header."
|
||||
#endif
|
||||
#include "filesystem.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
|
|
|
@ -42,16 +42,8 @@
|
|||
#include <array>
|
||||
#include <utility>
|
||||
#include <random>
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
error "Missing the <filesystem> header."
|
||||
#endif
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "game.h"
|
||||
#include "online_service.h"
|
||||
#include "stratagus.h"
|
||||
|
|
|
@ -692,13 +692,13 @@ std::vector<FileList> ReadDataDirectory(const fs::path& directory)
|
|||
{
|
||||
std::vector<FileList> files;
|
||||
|
||||
for (auto it = std::filesystem::directory_iterator{directory};
|
||||
it != std::filesystem::directory_iterator{};
|
||||
for (auto it = fs::directory_iterator{directory};
|
||||
it != fs::directory_iterator{};
|
||||
++it) {
|
||||
if (std::filesystem::is_directory(it->path())) {
|
||||
if (fs::is_directory(it->path())) {
|
||||
files.emplace_back();
|
||||
files.back().name = it->path().filename().string();
|
||||
} else if (std::filesystem::is_regular_file(it->path())) {
|
||||
} else if (fs::is_regular_file(it->path())) {
|
||||
files.emplace_back();
|
||||
files.back().name = it->path().filename().string();
|
||||
files.back().type = 1;
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "filesystem.h"
|
||||
#include "parameters.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef USE_WIN32
|
||||
#include <Shlobj.h>
|
||||
#include <filesystem>
|
||||
#endif
|
||||
|
||||
/* static */ Parameters Parameters::Instance;
|
||||
|
@ -59,7 +59,7 @@ void Parameters::SetDefaultUserDirectory(bool noPortable)
|
|||
if (!noPortable) {
|
||||
// if launcher is in the same directory as the data, we are in a portable install
|
||||
fs::path executable_path = GetExecutablePath();
|
||||
if (std::filesystem::equivalent(std::filesystem::path(StratagusLibPath), executable_path.parent_path())) {
|
||||
if (fs::equivalent(fs::path(StratagusLibPath), executable_path.parent_path())) {
|
||||
userDirectory = StratagusLibPath;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,23 +33,14 @@
|
|||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
error "Missing the <filesystem> header."
|
||||
#endif
|
||||
#include "script.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "script.h"
|
||||
|
||||
#include "animation/animation_setplayervar.h"
|
||||
#include "filesystem.h"
|
||||
#include "font.h"
|
||||
#include "game.h"
|
||||
#include "iolib.h"
|
||||
|
|
Loading…
Reference in a new issue