mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[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:
@@ -4,9 +4,9 @@
|
||||
|
||||
#include "LoggerImpl.h"
|
||||
|
||||
#include <wpi/Path.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/fs.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
using namespace nt;
|
||||
@@ -70,13 +70,12 @@ unsigned int LoggerImpl::GetMinLevel() {
|
||||
|
||||
void LoggerImpl::Log(unsigned int level, const char* file, unsigned int line,
|
||||
const char* msg) {
|
||||
// this is safe because it's null terminated and always the end
|
||||
const char* filename = wpi::sys::path::filename(file).data();
|
||||
auto filename = fs::path{file}.filename();
|
||||
{
|
||||
auto thr = GetThread();
|
||||
if (!thr || thr->m_listeners.empty()) {
|
||||
DefaultLogger(level, filename, line, msg);
|
||||
DefaultLogger(level, filename.string().c_str(), line, msg);
|
||||
}
|
||||
}
|
||||
Send(UINT_MAX, 0, level, filename, line, msg);
|
||||
Send(UINT_MAX, 0, level, filename.string().c_str(), line, msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user