]> git.cworth.org Git - apitrace/blobdiff - trace_file.cpp
Merge branch 'master' into compression
[apitrace] / trace_file.cpp
index 27b3eb18c07d10eb7e0a2fc3e5dc1bdd9e366b26..2a9705cd3350ffc49dacd604cde9ae137e47e82c 100644 (file)
@@ -6,6 +6,8 @@
 #include <zlib.h>
 #include <snappy.h>
 
+#include "os.hpp"
+
 #include <iostream>
 
 using namespace Trace;
@@ -52,6 +54,7 @@ bool File::open(const std::string &filename, File::Mode mode)
     }
     m_isOpened = rawOpen(filename, mode);
     m_mode = mode;
+
     return m_isOpened;
 }
 
@@ -79,9 +82,9 @@ void File::close()
     }
 }
 
-void File::flush()
+void File::flush(FlushType type)
 {
-    rawFlush();
+    rawFlush(type);
 }
 
 int File::getc()
@@ -165,7 +168,7 @@ void ZLibFile::rawClose()
     }
 }
 
-void ZLibFile::rawFlush()
+void ZLibFile::rawFlush(FlushType type)
 {
     gzflush(m_gzFile, Z_SYNC_FLUSH);
 }
@@ -267,6 +270,8 @@ bool SnappyFile::rawRead(void *buffer, int length)
             sizeToRead -= chunkSize;
             if (sizeToRead > 0)
                 flushCache();
+            if (!m_cacheSize)
+                break;
         }
     }
 
@@ -290,8 +295,11 @@ void SnappyFile::rawClose()
     m_cachePtr = NULL;
 }
 
-void SnappyFile::rawFlush()
+void SnappyFile::rawFlush(FlushType type)
 {
+    if (type == FlushDeep) {
+        flushCache();
+    }
     m_stream.flush();
 }