summaryrefslogtreecommitdiff
path: root/src/repo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo.cpp')
-rw-r--r--src/repo.cpp60
1 files changed, 44 insertions, 16 deletions
diff --git a/src/repo.cpp b/src/repo.cpp
index 634fe07..51f5fd1 100644
--- a/src/repo.cpp
+++ b/src/repo.cpp
@@ -48,17 +48,21 @@ GitFS::Repo::disconnect(const ::Ice::Current& current)
NetFS::DirectoryPrxPtr
GitFS::Repo::opendir(ReqEnv, ::std::string path, const ::Ice::Current& ice)
{
- if (path.empty()) throw NetFS::SystemError(EINVAL);
+ if (path.empty()) {
+ throw NetFS::SystemError(EINVAL);
+ }
return Ice::uncheckedCast<NetFS::DirectoryV2Prx>(ice.adapter->addWithUUID(
- std::make_shared<Directory>(this, path)));
+ std::make_shared<Directory>(this, std::move(path))));
}
NetFS::VFS
GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&)
{
- if (path.empty()) throw NetFS::SystemError(EINVAL);
+ if (path.empty()) {
+ throw NetFS::SystemError(EINVAL);
+ }
return {};
}
@@ -67,19 +71,33 @@ GitFS::Repo::statfs(ReqEnv, ::std::string path, const ::Ice::Current&)
int
GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&)
{
- if (mode & W_OK) return EACCES;
- if (path.empty()) return EINVAL;
- if (path == "/") return 0;
+ if (mode & W_OK) {
+ return EACCES;
+ }
+ if (path.empty()) {
+ return EINVAL;
+ }
+ if (path == "/") {
+ return 0;
+ }
try {
update();
auto e = Git::TreeEntryByPath(tree, path);
const auto emode = git_tree_entry_filemode(e.get());
- if (S_ISDIR(emode)) return 0;
- if (S_ISLNK(emode)) return 0;
- if (mode & R_OK && !(S_IRUSR & emode)) return EACCES;
- if (mode & X_OK && !(S_IXUSR & emode)) return EACCES;
+ if (S_ISDIR(emode)) {
+ return 0;
+ }
+ if (S_ISLNK(emode)) {
+ return 0;
+ }
+ if (mode & R_OK && !(S_IRUSR & emode)) {
+ return EACCES;
+ }
+ if (mode & X_OK && !(S_IXUSR & emode)) {
+ return EACCES;
+ }
return 0;
}
@@ -92,7 +110,9 @@ GitFS::Repo::access(ReqEnv, ::std::string path, int mode, const ::Ice::Current&)
NetFS::Attr
GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&)
{
- if (path.empty()) throw NetFS::SystemError(EINVAL);
+ if (path.empty()) {
+ throw NetFS::SystemError(EINVAL);
+ }
NetFS::Attr a {};
if (path == "/") {
@@ -117,11 +137,15 @@ GitFS::Repo::getattr(ReqEnv, ::std::string path, const ::Ice::Current&)
::std::string
GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&)
{
- if (path.empty() || path == "/") throw NetFS::SystemError(EINVAL);
+ if (path.empty() || path == "/") {
+ throw NetFS::SystemError(EINVAL);
+ }
update();
auto e = Git::TreeEntryByPath(tree, path);
- if (!S_ISLNK(git_tree_entry_filemode(e.get()))) throw NetFS::SystemError(EINVAL);
+ if (!S_ISLNK(git_tree_entry_filemode(e.get()))) {
+ throw NetFS::SystemError(EINVAL);
+ }
auto blob = Git::BlobLookup(repo, *git_tree_entry_id(e.get()));
auto n = static_cast<const ::std::string::value_type *>(git_blob_rawcontent(blob.get()));
return { n, n + git_blob_rawsize(blob.get()) };
@@ -131,12 +155,16 @@ GitFS::Repo::readlink(ReqEnv, ::std::string path, const ::Ice::Current&)
NetFS::FilePrxPtr
GitFS::Repo::open(ReqEnv, ::std::string path, int, const ::Ice::Current& ice)
{
- if (path.empty()) throw NetFS::SystemError(EINVAL);
- if (path == "/") throw NetFS::SystemError(EISDIR);
+ if (path.empty()) {
+ throw NetFS::SystemError(EINVAL);
+ }
+ if (path == "/") {
+ throw NetFS::SystemError(EISDIR);
+ }
update();
return Ice::uncheckedCast<NetFS::FilePrx>(ice.adapter->addWithUUID(
- std::make_shared<Blob>(this, path)));
+ std::make_shared<Blob>(this, std::move(path))));
}