Merge master; MXF subtitle stuff not included.
[libdcp.git] / asdcplib / src / KM_fileio.h
index 2f2718cdeeb92db785ecbaaa8a7ffc58d9aad665..cb00acc8d82ad52f50bc23b2b28977cadf265adf 100755 (executable)
@@ -34,6 +34,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <KM_util.h>
 #include <string>
+#include <boost/filesystem.hpp>
+#include <openssl/md5.h>
 
 #ifdef KM_WIN32
 # include <io.h>
@@ -51,24 +53,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace Kumu
 {
-  //
   class DirScanner
-    {
-    public:
-#ifdef KM_WIN32
-      __int64               m_Handle;
-      struct _finddatai64_t m_FileInfo;
-#else
-      DIR*       m_Handle;
-#endif
-
-      DirScanner(void);
-      ~DirScanner() { Close(); }
-
-      Result_t Open(const char*);
-      Result_t Close();
-      Result_t GetNext(char*);
-    };
+  {
+  public:
+         DirScanner();
+         Result_t Open(const char *);
+         Result_t GetNext(char *);
+         Result_t Close();
+  private:
+         boost::filesystem::directory_iterator _iterator;
+  };
 
 #ifdef KM_WIN32
   typedef __int64  fsize_t;
@@ -91,8 +85,8 @@ namespace Kumu
     SP_POS   = SEEK_CUR,
     SP_END   = SEEK_END
   };
-#endif
-
+#endif 
+       
   //
 #ifndef KM_SMALL_FILES_OK
   template <bool sizecheck>    void compile_time_size_checker();
@@ -305,6 +299,8 @@ namespace Kumu
       class h__iovec;
       mem_ptr<h__iovec>  m_IOVec;
       KM_NO_COPY_CONSTRUCT(FileWriter);
+      bool m_Hashing;
+      MD5_CTX m_MD5Context;
 
     public:
       FileWriter();
@@ -324,6 +320,10 @@ namespace Kumu
       // the iovec list will be written to disk before the given buffer,as though
       // you had called Writev() first.
       Result_t Write(const byte_t*, ui32_t, ui32_t* = 0);            // write buffer to disk
+
+      void StartHashing();
+      void MaybeHash(void const *, int);
+      std::string StopHashing();
    };
 
   Result_t CreateDirectoriesInPath(const std::string& Path);