[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

@@ -4,7 +4,7 @@
#pragma once
#include <wpi/SmallVector.h>
#include <string>
/** WPILib FileSystem namespace */
namespace frc::filesystem {
@@ -13,18 +13,18 @@ namespace frc::filesystem {
* Obtains the current working path that the program was launched with.
* This is analogous to the `pwd` command on unix.
*
* @param result The result of the current working path lookup.
* @return The result of the current working path lookup.
*/
void GetLaunchDirectory(wpi::SmallVectorImpl<char>& result);
std::string GetLaunchDirectory();
/**
* Obtains the operating directory of the program. On the roboRIO, this
* is /home/lvuser. In simulation, it is where the simulation was launched
* from (`pwd`).
*
* @param result The result of the operating directory lookup.
* @return The result of the operating directory lookup.
*/
void GetOperatingDirectory(wpi::SmallVectorImpl<char>& result);
std::string GetOperatingDirectory();
/**
* Obtains the deploy directory of the program, which is the remote location
@@ -32,8 +32,8 @@ void GetOperatingDirectory(wpi::SmallVectorImpl<char>& result);
* /home/lvuser/deploy. In simulation, it is where the simulation was launched
* from, in the subdirectory "src/main/deploy" (`pwd`/src/main/deploy).
*
* @param result The result of the operating directory lookup
* @return The result of the operating directory lookup
*/
void GetDeployDirectory(wpi::SmallVectorImpl<char>& result);
std::string GetDeployDirectory();
} // namespace frc::filesystem