From 67684b3a9a7205cef15f5978b5adc4df632f5af5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 21 Jul 2019 13:54:41 +0100 Subject: Basically all the core functionality --- src/git.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/git.cpp') diff --git a/src/git.cpp b/src/git.cpp index 084e6ca..850b8b3 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1,6 +1,8 @@ #include "git.h" #include #include +#include +#include namespace GitFS { namespace Git { @@ -14,6 +16,45 @@ namespace GitFS { #endif throw Error { err, e->klass, e->message }; } + + [[noreturn]] void ErrorToSystemError(const Error & e) + { + if (e.err == GIT_ENOTFOUND) { + throw NetFS::SystemError(ENOENT); + } + throw NetFS::SystemError(EIO); + } + + } +} + +namespace NetFS { + Attr & operator<<(Attr & a, const git_tree_entry & e) + { + a.mode = git_tree_entry_filemode(&e); + if (S_ISDIR(a.mode)) { + a.mode |= S_IXUSR | S_IXGRP | S_IXOTH | S_IRUSR | S_IRGRP | S_IROTH; + } + else if (S_ISLNK(a.mode)) { + a.mode |= S_IRUSR | S_IRGRP | S_IROTH; + } + else { + a.mode ^= S_IWUSR; + } + return a; + } + + Attr & operator<<(Attr & a, const git_commit & c) + { + a.ctime = a.atime = a.mtime = git_commit_time(&c); + return a; + } + + Attr & operator<<(Attr & a, const git_blob & b) + { + a.blockSize = 1; + a.blocks = a.size = git_blob_rawsize(&b); + return a; } } -- cgit v1.2.3