From 83615c6024c28f55c29947f2ada08323c8a9e1e8 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Thu, 3 Oct 2024 15:32:09 -0400 Subject: [PATCH] [wpiutil] DataLogBackgroundWriter: Normalize empty path name (#7151) An empty path isn't valid on it's own, so fs::space always returns an error. This results in UINT_MAX bytes being used instead of the actual free space, which means a default constructed DataLogBackgroundWriter won't stop for low space. Using "." instead makes the directory path the current working directory, which is the desired behavior --- wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp b/wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp index b20d4b7390..9b7a52c9d0 100644 --- a/wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp +++ b/wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp @@ -176,7 +176,8 @@ static std::string MakeRandomFilename() { } struct DataLogBackgroundWriter::WriterThreadState { - explicit WriterThreadState(std::string_view dir) : dirPath{dir} {} + explicit WriterThreadState(std::string_view dir) + : dirPath{dir.empty() ? "." : dir} {} WriterThreadState(const WriterThreadState&) = delete; WriterThreadState& operator=(const WriterThreadState&) = delete; ~WriterThreadState() { Close(); }