mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpiutil] Return wpi::expected from MemoryBuffer::GetFile (#7069)
This commit is contained in:
@@ -540,16 +540,14 @@ bool FieldInfo::LoadJson(std::span<const char> is, std::string_view filename) {
|
||||
}
|
||||
|
||||
void FieldInfo::LoadJsonFile(std::string_view jsonfile) {
|
||||
std::error_code ec;
|
||||
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
|
||||
wpi::MemoryBuffer::GetFile(jsonfile, ec);
|
||||
if (fileBuffer == nullptr || ec) {
|
||||
auto fileBuffer = wpi::MemoryBuffer::GetFile(jsonfile);
|
||||
if (!fileBuffer) {
|
||||
std::fputs("GUI: could not open field JSON file\n", stderr);
|
||||
return;
|
||||
}
|
||||
LoadJson(
|
||||
{reinterpret_cast<const char*>(fileBuffer->begin()), fileBuffer->size()},
|
||||
jsonfile);
|
||||
LoadJson({reinterpret_cast<const char*>(fileBuffer.value()->begin()),
|
||||
fileBuffer.value()->size()},
|
||||
jsonfile);
|
||||
}
|
||||
|
||||
bool FieldInfo::LoadImageImpl(const std::string& fn) {
|
||||
|
||||
Reference in New Issue
Block a user