Skip to content

Commit

Permalink
[wpiutil] DataLogBackgroundWriter: Normalize empty path name (wpilibs…
Browse files Browse the repository at this point in the history
…uite#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
  • Loading branch information
rzblue authored and Gold856 committed Oct 10, 2024
1 parent b903ec2 commit fb96c68
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wpiutil/src/main/native/cpp/DataLogBackgroundWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down

0 comments on commit fb96c68

Please sign in to comment.