Add filesystem header to select between std::filesystem and std::experimental::filesystem depending on system availability.
Commit amended by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
05d72ba96f
commit
ad2cd89128
6 changed files with 33 additions and 21 deletions
|
|
@ -4,9 +4,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
#include "filesystem.h"
|
||||||
#include <experimental/filesystem>
|
|
||||||
namespace fs = std::experimental::filesystem;
|
|
||||||
|
|
||||||
static const char* log_codes[] = {"CRITICAL", "ERROR", "Message", "Warning", "Notice", "[verbose]", "Debug"};
|
static const char* log_codes[] = {"CRITICAL", "ERROR", "Message", "Warning", "Notice", "[verbose]", "Debug"};
|
||||||
|
|
||||||
|
|
@ -77,13 +75,13 @@ void LogManager::configure(json config, const std::string &defaultDir)
|
||||||
/*-------------------------------------------------*\
|
/*-------------------------------------------------*\
|
||||||
| If the path is relative, use logs dir |
|
| If the path is relative, use logs dir |
|
||||||
\*-------------------------------------------------*/
|
\*-------------------------------------------------*/
|
||||||
fs::path p = logname;
|
filesystem::path p = logname;
|
||||||
if(p.is_relative())
|
if(p.is_relative())
|
||||||
{
|
{
|
||||||
p = defaultDir + "logs/";
|
p = defaultDir + "logs/";
|
||||||
p.append(logname);
|
p.append(logname);
|
||||||
}
|
}
|
||||||
fs::create_directories(p.parent_path());
|
filesystem::create_directories(p.parent_path());
|
||||||
|
|
||||||
/*-------------------------------------------------*\
|
/*-------------------------------------------------*\
|
||||||
| Open the logfile |
|
| Open the logfile |
|
||||||
|
|
|
||||||
12
OpenRGB.pro
12
OpenRGB.pro
|
|
@ -11,6 +11,11 @@ QT +=
|
||||||
core \
|
core \
|
||||||
gui \
|
gui \
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------------------------#
|
||||||
|
# Set compiler to use C++17 to make std::filesystem available #
|
||||||
|
#-----------------------------------------------------------------------------------------------#
|
||||||
|
CONFIG += c++17
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 5): DEFINES += _QT6
|
greaterThan(QT_MAJOR_VERSION, 5): DEFINES += _QT6
|
||||||
|
|
@ -134,6 +139,7 @@ HEADERS +=
|
||||||
SettingsManager.h \
|
SettingsManager.h \
|
||||||
Detector.h \
|
Detector.h \
|
||||||
DeviceDetector.h \
|
DeviceDetector.h \
|
||||||
|
filesystem.h \
|
||||||
qt/DetectorTableModel.h \
|
qt/DetectorTableModel.h \
|
||||||
qt/OpenRGBClientInfoPage.h \
|
qt/OpenRGBClientInfoPage.h \
|
||||||
qt/OpenRGBDeviceInfoPage.h \
|
qt/OpenRGBDeviceInfoPage.h \
|
||||||
|
|
@ -788,9 +794,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
TARGET = $$lower($$TARGET)
|
TARGET = $$lower($$TARGET)
|
||||||
|
|
||||||
CONFIG += \
|
|
||||||
c++14 \
|
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
Controllers/FaustusController \
|
Controllers/FaustusController \
|
||||||
Controllers/LinuxLEDController \
|
Controllers/LinuxLEDController \
|
||||||
|
|
@ -884,9 +887,6 @@ macx {
|
||||||
LIBS += \
|
LIBS += \
|
||||||
-lusb-1.0 \
|
-lusb-1.0 \
|
||||||
-lhidapi \
|
-lhidapi \
|
||||||
|
|
||||||
CONFIG += \
|
|
||||||
c++14 \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------------------#
|
#-------------------------------------------------------------------------------------------#
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,15 @@
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
#include "RGBController_Dummy.h"
|
#include "RGBController_Dummy.h"
|
||||||
#include "LogManager.h"
|
#include "LogManager.h"
|
||||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
#include "filesystem.h"
|
||||||
#include <experimental/filesystem>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
#define OPENRGB_PROFILE_HEADER "OPENRGB_PROFILE"
|
#define OPENRGB_PROFILE_HEADER "OPENRGB_PROFILE"
|
||||||
#define OPENRGB_PROFILE_VERSION OPENRGB_SDK_PROTOCOL_VERSION
|
#define OPENRGB_PROFILE_VERSION OPENRGB_SDK_PROTOCOL_VERSION
|
||||||
|
|
||||||
namespace fs = std::experimental::filesystem;
|
|
||||||
|
|
||||||
ProfileManager::ProfileManager(std::string config_dir)
|
ProfileManager::ProfileManager(std::string config_dir)
|
||||||
{
|
{
|
||||||
configuration_directory = config_dir;
|
configuration_directory = config_dir;
|
||||||
|
|
@ -389,7 +387,7 @@ void ProfileManager::UpdateProfileList()
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Load profiles by looking for .orp files in current dir |
|
| Load profiles by looking for .orp files in current dir |
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
for(const auto & entry : fs::directory_iterator(configuration_directory))
|
for(const auto & entry : filesystem::directory_iterator(configuration_directory))
|
||||||
{
|
{
|
||||||
std::string filename = entry.path().filename().string();
|
std::string filename = entry.path().filename().string();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,8 @@
|
||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
#include "ProfileManager.h"
|
#include "ProfileManager.h"
|
||||||
#include "LogManager.h"
|
#include "LogManager.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
|
||||||
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
|
||||||
#include <experimental/filesystem>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <hidapi/hidapi.h>
|
#include <hidapi/hidapi.h>
|
||||||
|
|
@ -307,7 +306,7 @@ std::string ResourceManager::GetConfigurationDirectory()
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
| Create OpenRGB configuration directory if it doesn't exist |
|
| Create OpenRGB configuration directory if it doesn't exist |
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
std::experimental::filesystem::create_directories(config_dir);
|
filesystem::create_directories(config_dir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
17
filesystem.h
Normal file
17
filesystem.h
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef FILESYSTEM_H
|
||||||
|
#define FILESYSTEM_H
|
||||||
|
|
||||||
|
#if defined(__has_include) && __has_include(<filesystem>)
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
namespace filesystem = std::filesystem;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
||||||
|
#include <experimental/filesystem>
|
||||||
|
namespace filesystem = std::experimental::filesystem;
|
||||||
|
|
||||||
|
#endif // C++17
|
||||||
|
|
||||||
|
#endif // FILESYSTEM_H
|
||||||
|
|
@ -10,8 +10,8 @@ index 6295344a..d09bed44 100644
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
- TARGET = $$lower($$TARGET)
|
- TARGET = $$lower($$TARGET)
|
||||||
-
|
-
|
||||||
CONFIG += \
|
INCLUDEPATH += \
|
||||||
c++14 \
|
Controllers/FaustusController \
|
||||||
|
|
||||||
diff --git a/qt/OpenRGB.desktop b/qt/OpenRGB.desktop
|
diff --git a/qt/OpenRGB.desktop b/qt/OpenRGB.desktop
|
||||||
index bd71a38a..b4a0f86a 100644
|
index bd71a38a..b4a0f86a 100644
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue