mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
feat(tree): add bindings and api
This commit is contained in:
parent
6bd04bb09d
commit
84ee4be945
22 changed files with 316 additions and 84 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue