binarystore: Add std::optional for optional config options
The `maxSizeBytes` was using 0 size by default instead of skipping it.
Letting `config.maxSizeBytes` be std::optional allow us to have more
control to see if the 0 value is expected or nullopt.
Change-Id: I128216825609909c489cbd5471b324d88d3aa25b
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/src/sys_file_impl.cpp b/src/sys_file_impl.cpp
index 243d82d..9fab76a 100644
--- a/src/sys_file_impl.cpp
+++ b/src/sys_file_impl.cpp
@@ -1,5 +1,6 @@
#include "sys_file_impl.hpp"
+#include <optional>
#include <system_error>
using namespace std::string_literals;
@@ -19,12 +20,12 @@
} // namespace
-SysFileImpl::SysFileImpl(const std::string& path, size_t offset,
+SysFileImpl::SysFileImpl(const std::string& path, std::optional<size_t> offset,
const internal::Sys* sys) :
sys(sys)
{
fd_ = sys->open(path.c_str(), O_RDWR);
- offset_ = offset;
+ offset_ = offset ? *offset : 0;
if (fd_ < 0)
{