hash handler: implement file hash handler

Implement the hash handler as a generic file handler as there is not
likely to be any magic required for it.

Change-Id: I82ac102c720718504aa3dbcae0b13031349d6121
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/file_handler.hpp b/file_handler.hpp
new file mode 100644
index 0000000..c419949
--- /dev/null
+++ b/file_handler.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "image_handler.hpp"
+
+#include <cstdint>
+#include <fstream>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace blobs
+{
+
+class FileHandler : public ImageHandlerInterface
+{
+  public:
+    /**
+     * Create a FileHandler.  This object is basically a filewriter.
+     *
+     * @param[in] filename - file to use for the contents, fully
+     * qualified file system path.
+     */
+    explicit FileHandler(const std::string& filename) : filename(filename)
+    {
+    }
+
+    bool open(const std::string& path) override;
+    void close() override;
+    bool write(std::uint32_t offset,
+               const std::vector<std::uint8_t>& data) override;
+
+  private:
+    /** the active hash path, ignore. */
+    std::string path;
+
+    /** The file handle. */
+    std::ofstream file;
+
+    /** The filename (including path) to use to write bytes. */
+    std::string filename;
+};
+
+} // namespace blobs