changeset 40:516b6e731bb5

added support for ReadRange in google plugin
author Alain Mazy <am@osimis.io>
date Fri, 19 Mar 2021 09:34:29 +0100
parents 50d0be413c42
children d99afdf6d872
files Google/GoogleStoragePlugin.cpp
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Google/GoogleStoragePlugin.cpp	Wed Mar 17 16:02:53 2021 +0100
+++ b/Google/GoogleStoragePlugin.cpp	Fri Mar 19 09:34:29 2021 +0100
@@ -103,7 +103,7 @@
     }
   }
 
-  virtual void Read(char* data, size_t size)
+  virtual void ReadWhole(char* data, size_t size)
   {
     auto reader = client_.ReadObject(bucketName_, path_);
 
@@ -120,6 +120,24 @@
     }
   }
 
+  virtual void ReadRange(char* data, size_t size, size_t fromOffset)
+  {
+    auto reader = client_.ReadObject(bucketName_, path_, gcs::ReadRange(fromOffset, fromOffset + size));
+
+    if (!reader)
+    {
+      throw StoragePluginException("error while opening/reading file " + std::string(path_) + ": " + reader.status().message());
+    }
+
+    reader.read(data, size);
+
+    if (!reader)
+    {
+      throw StoragePluginException("error while reading file " + std::string(path_) + ": " + reader.status().message());
+    }
+  }
+
+
 };