extend file_handler to support reads

Problem: the upcomming version handler will need to read from files.
Currently file hander (image handler) does not support reads.

Solution: Add read support by providing an optional mode parameter.

Tests added:
FileHanderTest added to
- Test out open for reads
- Test out reading out bytes and verifying size and content
- Test out trying to read beyond EOF
- Test out offset reads that go beyond EOF

Tested:
Existing unit tests pass
New unit tests for reading all pass

Signed-off-by: Jason Ling <jasonling@google.com>
Change-Id: Ie416a6b4b452d8d04fa158bd55989d07a891896f
diff --git a/bmc/file_handler.hpp b/bmc/file_handler.hpp
index 0c00d2d..bf31f40 100644
--- a/bmc/file_handler.hpp
+++ b/bmc/file_handler.hpp
@@ -23,10 +23,13 @@
     explicit FileHandler(const std::string& filename) : filename(filename)
     {}
 
-    bool open(const std::string& path) override;
+    bool open(const std::string& path,
+              std::ios_base::openmode mode = std::ios::out) override;
     void close() override;
     bool write(std::uint32_t offset,
                const std::vector<std::uint8_t>& data) override;
+    virtual std::optional<std::vector<uint8_t>>
+        read(std::uint32_t offset, std::uint32_t size) override;
     int getSize() override;
 
   private:
@@ -34,7 +37,7 @@
     std::string path;
 
     /** The file handle. */
-    std::ofstream file;
+    std::fstream file;
 
     /** The filename (including path) to use to write bytes. */
     std::string filename;