feat(tree): add bindings and api

This commit is contained in:
Aleksey Kulikov 2021-09-02 11:58:14 +03:00
parent 6bd04bb09d
commit 84ee4be945
22 changed files with 316 additions and 84 deletions

View file

@ -1,6 +1,7 @@
import 'dart:ffi';
import 'dart:io';
import 'dart:ffi';
import 'bindings/libgit2_bindings.dart';
import 'enums.dart';
DynamicLibrary loadLibrary() {
if (Platform.isLinux || Platform.isAndroid || Platform.isFuchsia) {
@ -25,3 +26,39 @@ bool isValidShaHex(String str) {
return hexRegExp.hasMatch(str) &&
(GIT_OID_MINPREFIXLEN <= str.length && GIT_OID_HEXSZ >= str.length);
}
GitFilemode intToGitFilemode(int i) {
switch (i) {
case 0:
return GitFilemode.undreadable;
case 16384:
return GitFilemode.tree;
case 33188:
return GitFilemode.blob;
case 33261:
return GitFilemode.blobExecutable;
case 40960:
return GitFilemode.link;
case 57344:
return GitFilemode.commit;
default:
return GitFilemode.undreadable;
}
}
int gitFilemodeToInt(GitFilemode filemode) {
switch (filemode) {
case GitFilemode.undreadable:
return 0;
case GitFilemode.tree:
return 16384;
case GitFilemode.blob:
return 33188;
case GitFilemode.blobExecutable:
return 33261;
case GitFilemode.link:
return 40960;
case GitFilemode.commit:
return 57344;
}
}