idmap2: switch to improved Result class
Remove the old std::optional based Result class, replace uses with the
new std::variant based Result class.
Test: make idmap2_tests
Change-Id: I401cb36e5af06133a2872d835cf29bfb0b106597
diff --git a/cmds/idmap2/libidmap2/ZipFile.cpp b/cmds/idmap2/libidmap2/ZipFile.cpp
index 15ec3f9..0f07324 100644
--- a/cmds/idmap2/libidmap2/ZipFile.cpp
+++ b/cmds/idmap2/libidmap2/ZipFile.cpp
@@ -59,7 +59,10 @@
Result<uint32_t> ZipFile::Crc(const std::string& entryPath) const {
::ZipEntry entry;
int32_t status = ::FindEntry(handle_, ::ZipString(entryPath.c_str()), &entry);
- return status == 0 ? Result<uint32_t>(entry.crc32) : kResultError;
+ if (status != 0) {
+ return Error("failed to find zip entry %s", entryPath.c_str());
+ }
+ return entry.crc32;
}
} // namespace android::idmap2