]> git.cworth.org Git - apitrace/blobdiff - common/trace_file_snappy.cpp
retrace: Implement glxCopySubBufferMESA
[apitrace] / common / trace_file_snappy.cpp
index e4c17cd1755d7d2024e6a6fa4f30861912056436..41d86ea00ded834e33dadd3a3ca65c5d5ef7da63 100644 (file)
@@ -54,6 +54,7 @@
 #include <snappy.h>
 
 #include <iostream>
+#include <algorithm>
 
 #include <assert.h>
 #include <string.h>
@@ -63,8 +64,6 @@
 
 #define SNAPPY_CHUNK_SIZE (1 * 1024 * 1024)
 
-#define SNAPPY_BYTE1 'a'
-#define SNAPPY_BYTE2 't'
 
 
 using namespace trace;
@@ -241,7 +240,7 @@ size_t SnappyFile::rawRead(void *buffer, size_t length)
 
 int SnappyFile::rawGetc()
 {
-    int c = 0;
+    unsigned char c = 0;
     if (rawRead(&c, 1) != 1)
         return -1;
     return c;
@@ -399,25 +398,10 @@ bool SnappyFile::rawSkip(size_t length)
 
 int SnappyFile::rawPercentRead()
 {
-    return 100 * (double(m_stream.tellg()) / double(m_endPos));
+    return int(100 * (double(m_stream.tellg()) / double(m_endPos)));
 }
 
 
 File* File::createSnappy(void) {
     return new SnappyFile;
 }
-
-bool File::isSnappyCompressed(const std::string &filename)
-{
-    std::fstream stream(filename.c_str(),
-                        std::fstream::binary | std::fstream::in);
-    if (!stream.is_open())
-        return false;
-
-    unsigned char byte1, byte2;
-    stream >> byte1;
-    stream >> byte2;
-    stream.close();
-
-    return (byte1 == SNAPPY_BYTE1 && byte2 == SNAPPY_BYTE2);
-}