summaryrefslogtreecommitdiff
path: root/src/blob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/blob.cpp')
-rw-r--r--src/blob.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/blob.cpp b/src/blob.cpp
new file mode 100644
index 0000000..8fb0509
--- /dev/null
+++ b/src/blob.cpp
@@ -0,0 +1,49 @@
+#include <Ice/ObjectAdapter.h>
+#include "blob.h"
+
+GitFS::Blob::Blob(const GitFS::Git::RepositoryPtr & r, const GitFS::Git::TreeEntryPtr & te) :
+ blob(Git::BlobLookup(r, *git_tree_entry_id(te.get()))),
+ blobSize(git_blob_rawsize(blob.get())),
+ blobContent(static_cast<const char *>(git_blob_rawcontent(blob.get())))
+{
+}
+
+void
+GitFS::Blob::close(const ::Ice::Current& current)
+{
+ current.adapter->remove(current.id);
+}
+
+
+NetFS::Attr
+GitFS::Blob::fgetattr(ReqEnv, const ::Ice::Current&)
+{
+ return {};
+}
+
+
+NetFS::Buffer
+GitFS::Blob::read(long long int offset, long long int size, const ::Ice::Current&)
+{
+ if (offset > blobSize) {
+ return {};
+ }
+ auto len = std::min(blobSize - offset, size);
+ return NetFS::Buffer(blobContent + offset, blobContent + offset + len);
+}
+
+
+void
+GitFS::Blob::ftruncate(ReqEnv, long long int, const ::Ice::Current&)
+{
+ throw NetFS::SystemError(EROFS);
+}
+
+
+void
+GitFS::Blob::write(long long int, long long int, Buffer, const ::Ice::Current&)
+{
+ throw NetFS::SystemError(EROFS);
+}
+
+