summaryrefslogtreecommitdiff
path: root/src/blob.cpp
blob: 8fb0509a022e1ca488203929f80d067eccdc9128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}