add platform::open_folder
This commit is contained in:
parent
2a150049c6
commit
6964a18605
@ -7,12 +7,11 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "typedefs.hpp"
|
||||
#include "stringutil.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
||||
#include "stringutil.hpp"
|
||||
|
||||
void platform::configure_encoding() {
|
||||
// set utf-8 encoding to console output
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
@ -35,7 +34,6 @@ std::string platform::detect_locale() {
|
||||
.replace(2, 1, "_")
|
||||
.substr(0, 5);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void platform::configure_encoding() {
|
||||
@ -49,5 +47,19 @@ std::string platform::detect_locale() {
|
||||
|
||||
return preferredLocaleName.substr(0, 5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void platform::open_folder(const std::filesystem::path& folder) {
|
||||
if (!std::filesystem::is_directory(folder)) {
|
||||
return;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
auto cmd = "open "+util::quote(folder.u8string());
|
||||
#elif defined(_WIN32)
|
||||
auto cmd = "start "+util::quote(folder.u8string());
|
||||
#else
|
||||
auto cmd = "xdg-open "+util::quote(folder.u8string());
|
||||
#endif
|
||||
system(cmd.c_str());
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
namespace platform {
|
||||
void configure_encoding();
|
||||
// @return environment locale in ISO format ll_CC
|
||||
/// @return environment locale in ISO format ll_CC
|
||||
std::string detect_locale();
|
||||
/// @brief Open folder using system file manager application
|
||||
/// @param folder target folder
|
||||
void open_folder(const std::filesystem::path& folder);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user