[wpiutil] Replace llvm filesystem with C++17 filesystem (#3401)

Use ghc::filesystem as fill on older GCC (e.g. RoboRIO).
This can be removed once all GCC platforms have upgraded to 8.1 or later.

File open functionality has been retained from LLVM but moved to "fs" namespace
and tweaked for improved consistency with std::filesystem (e.g. error_code is
passed by reference instead of returned).

Also update WPILibC's Filesystem functions to return std::string.
This commit is contained in:
Peter Johnson
2021-06-01 21:50:35 -07:00
committed by GitHub
parent 01dc0249de
commit fe570e000c
25 changed files with 6757 additions and 3538 deletions

View File

@@ -6,9 +6,9 @@
#include <vector>
#include <wpi/Path.h>
#include <wpi/SmallString.h>
#include <wpi/StringRef.h>
#include <wpi/fs.h>
#include <wpi/raw_ostream.h>
#include <wpi/spinlock.h>
@@ -54,7 +54,7 @@ extern "C" {
int HAL_LoadOneExtension(const char* library) {
int rc = 1; // It is expected and reasonable not to find an extra simulation
wpi::outs() << "HAL Extensions: Attempting to load: "
<< wpi::sys::path::stem(library) << "\n";
<< fs::path{library}.stem().string() << "\n";
wpi::outs().flush();
HTYPE handle = DLOPEN(library);
#if !defined(WIN32) && !defined(_WIN32)
@@ -68,7 +68,7 @@ int HAL_LoadOneExtension(const char* library) {
#endif
wpi::outs() << "HAL Extensions: Load failed: " << DLERROR
<< "\nTrying modified name: "
<< wpi::sys::path::stem(libraryName) << "\n";
<< fs::path{libraryName.str()}.stem() << "\n";
wpi::outs().flush();
handle = DLOPEN(libraryName.c_str());
}