mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpiutil] Change kInvalidFile to macro (#7750)
This is needed on Windows because accessing global variables across shared library boundaries doesn’t work.
This commit is contained in:
@@ -183,9 +183,9 @@ struct DataLogBackgroundWriter::WriterThreadState {
|
||||
~WriterThreadState() { Close(); }
|
||||
|
||||
void Close() {
|
||||
if (f != fs::kInvalidFile) {
|
||||
if (f != WPI_kInvalidFile) {
|
||||
fs::CloseFile(f);
|
||||
f = fs::kInvalidFile;
|
||||
f = WPI_kInvalidFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ struct DataLogBackgroundWriter::WriterThreadState {
|
||||
std::string baseFilename;
|
||||
std::string filename;
|
||||
fs::path path;
|
||||
fs::file_t f = fs::kInvalidFile;
|
||||
fs::file_t f = WPI_kInvalidFile;
|
||||
uintmax_t freeSpace = UINTMAX_MAX;
|
||||
int segmentCount = 1;
|
||||
};
|
||||
@@ -264,7 +264,7 @@ void DataLogBackgroundWriter::StartLogFile(WriterThreadState& state) {
|
||||
}
|
||||
}
|
||||
|
||||
if (state.f == fs::kInvalidFile) {
|
||||
if (state.f == WPI_kInvalidFile) {
|
||||
WPI_ERROR(m_msglog, "Could not open log file, no log being saved");
|
||||
} else {
|
||||
WPI_INFO(m_msglog, "Logging to '{}' ({} free space)", state.path.string(),
|
||||
@@ -273,7 +273,7 @@ void DataLogBackgroundWriter::StartLogFile(WriterThreadState& state) {
|
||||
}
|
||||
|
||||
// start file
|
||||
if (state.f != fs::kInvalidFile) {
|
||||
if (state.f != WPI_kInvalidFile) {
|
||||
StartFile();
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ void DataLogBackgroundWriter::WriterThreadMain(std::string_view dir) {
|
||||
written = 0;
|
||||
}
|
||||
|
||||
if (!m_newFilename.empty() && state.f != fs::kInvalidFile) {
|
||||
if (!m_newFilename.empty() && state.f != WPI_kInvalidFile) {
|
||||
auto newFilename = std::move(m_newFilename);
|
||||
m_newFilename.clear();
|
||||
// rename
|
||||
@@ -374,7 +374,7 @@ void DataLogBackgroundWriter::WriterThreadMain(std::string_view dir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state.f != fs::kInvalidFile && !blocked) {
|
||||
if (state.f != WPI_kInvalidFile && !blocked) {
|
||||
lock.unlock();
|
||||
|
||||
// update free space every 10 flushes (in case other things are writing)
|
||||
|
||||
Reference in New Issue
Block a user