Inject sysfile dependency when creating BinaryStore

Make the factory take sysFile rather than raw fd. Test code would take
a FakeSysFile for testing file operations.

Change-Id: Id7a02203893936e4eddb2e73267b45343c6c6f08
Signed-off-by: Kun Yi <kunyi@google.com>
diff --git a/binarystore.cpp b/binarystore.cpp
index 1e8475c..98a6264 100644
--- a/binarystore.cpp
+++ b/binarystore.cpp
@@ -22,11 +22,20 @@
 
 std::unique_ptr<BinaryStoreInterface>
     BinaryStore::createFromConfig(const std::string& baseBlobId,
-                                  const std::string& sysfilePath,
-                                  uint32_t offset, uint32_t maxSize)
+                                  std::unique_ptr<SysFile> file,
+                                  uint32_t maxSize)
 {
-    // TODO: implement sysFile parsing
-    return std::make_unique<BinaryStore>(baseBlobId, 0, offset, maxSize);
+    if (baseBlobId.empty() || !file)
+    {
+        return nullptr;
+    }
+
+    auto store =
+        std::make_unique<BinaryStore>(baseBlobId, std::move(file), maxSize);
+
+    store->blob_.set_blob_base_id(store->baseBlobId_);
+
+    return std::move(store);
 }
 
 std::string BinaryStore::getBaseBlobId() const