diff Core/Compression/DeflateBaseCompressor.cpp @ 1513:fe07f82d83d3

gzip compression
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Aug 2015 16:01:37 +0200
parents 52dc56bcec7d
children bd1889029cbb
line wrap: on
line diff
--- a/Core/Compression/DeflateBaseCompressor.cpp	Mon Aug 10 14:52:10 2015 +0200
+++ b/Core/Compression/DeflateBaseCompressor.cpp	Mon Aug 10 16:01:37 2015 +0200
@@ -35,6 +35,8 @@
 
 #include "../OrthancException.h"
 
+#include <string.h>
+
 namespace Orthanc
 {
   void DeflateBaseCompressor::SetCompressionLevel(uint8_t level)
@@ -46,4 +48,25 @@
 
     compressionLevel_ = level;
   }
+
+
+  uint64_t DeflateBaseCompressor::ReadUncompressedSizePrefix(const void* compressed,
+                                                             size_t compressedSize)
+  {
+    if (compressedSize == 0)
+    {
+      return 0;
+    }
+
+    if (compressedSize < sizeof(uint64_t))
+    {
+      throw OrthancException("The compressed buffer is ill-formed");
+    }
+
+    uint64_t size;
+    memcpy(&size, compressed, sizeof(uint64_t));
+
+    return size;
+  }
+
 }