Make use of std::filesystem optional
It is not available under Android yet and only used for Bash completion. So make it optional to support Android by disabling that part of the Bash completion which is not useful under Android anyways.
This commit is contained in:
parent
6b1a9cec01
commit
1be20da35a
|
@ -160,8 +160,14 @@ else ()
|
|||
message(STATUS "Using std::fstream for NativeFileStream")
|
||||
endif ()
|
||||
|
||||
# configure required libraries for std::filestream
|
||||
# configure required libraries for std::filesystem
|
||||
option(USE_STANDARD_FILESYSTEM "uses std::filesystem; if disabled Bash completion for files and directories is not working" ON)
|
||||
if (USE_STANDARD_FILESYSTEM)
|
||||
list(APPEND META_PRIVATE_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_USE_STANDARD_FILESYSTEM)
|
||||
use_standard_filesystem()
|
||||
else ()
|
||||
message(WARNING "The use of std::filesystem has been disabled. Bash completion for files and directories will not work.")
|
||||
endif ()
|
||||
|
||||
# configure forcing UTF-8 code page under Windows
|
||||
option(FORCE_UTF8_CODEPAGE "forces use of UTF-8 code page under Windows via ApplicationUtilities::startConsole()" OFF)
|
||||
|
|
|
@ -12,12 +12,15 @@
|
|||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
|
||||
#include <filesystem>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace std::literals;
|
||||
|
@ -1484,6 +1487,7 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi
|
|||
}
|
||||
|
||||
// -> completion for files and dirs
|
||||
#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
|
||||
if (completionInfo.completeFiles || completionInfo.completeDirs) {
|
||||
using namespace std::filesystem;
|
||||
const auto replace = "'"s, with = "'\"'\"'"s;
|
||||
|
@ -1520,6 +1524,7 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi
|
|||
haveFileOrDirCompletions = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
cout << ')';
|
||||
|
||||
// ensure file or dir completions are formatted appropriately
|
||||
|
|
|
@ -659,9 +659,13 @@ void ArgumentParserTests::testBashCompletion()
|
|||
parser.resetArgs();
|
||||
const char *const argv5[] = { "get", "--files", iniFilePath.c_str() };
|
||||
{
|
||||
#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
|
||||
// order for file names is not specified
|
||||
const OutputCheck c("COMPREPLY=('" % mkvFilePath % " '\"'\"'with quote'\"'\"'.mkv' '" % iniFilePath + ".ini' ); compopt -o filenames\n",
|
||||
"COMPREPLY=('" % iniFilePath % ".ini' '" % mkvFilePath + " '\"'\"'with quote'\"'\"'.mkv' ); compopt -o filenames\n");
|
||||
#else
|
||||
const OutputCheck c("COMPREPLY=()\n");
|
||||
#endif
|
||||
reader.reset(argv5, argv5 + 3).read();
|
||||
parser.printBashCompletion(3, argv5, 2, reader);
|
||||
}
|
||||
|
@ -672,8 +676,12 @@ void ArgumentParserTests::testBashCompletion()
|
|||
parser.resetArgs();
|
||||
const char *const argv14[] = { "get", "--files", directoryPath.c_str() };
|
||||
{
|
||||
#ifdef CPP_UTILITIES_USE_STANDARD_FILESYSTEM
|
||||
// order for file names is not specified
|
||||
const OutputCheck c("COMPREPLY=('" % directoryPath + "subdir' ); compopt -o filenames\n");
|
||||
#else
|
||||
const OutputCheck c("COMPREPLY=()\n");
|
||||
#endif
|
||||
reader.reset(argv14, argv14 + 3).read();
|
||||
parser.printBashCompletion(3, argv14, 2, reader);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue