mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
refactor: use extensions (#62)
This commit is contained in:
parent
4aea9a306a
commit
3d235f5ce4
47 changed files with 386 additions and 355 deletions
|
@ -4,6 +4,7 @@ import 'package:ffi/ffi.dart';
|
|||
|
||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||
import 'package:libgit2dart/src/error.dart';
|
||||
import 'package:libgit2dart/src/extensions.dart';
|
||||
import 'package:libgit2dart/src/util.dart';
|
||||
|
||||
/// Lookup a blob object from a repository. The returned blob must be freed
|
||||
|
@ -84,7 +85,7 @@ Pointer<git_oid> createFromWorkdir({
|
|||
required String relativePath,
|
||||
}) {
|
||||
final out = calloc<git_oid>();
|
||||
final relativePathC = relativePath.toNativeUtf8().cast<Char>();
|
||||
final relativePathC = relativePath.toChar();
|
||||
final error = libgit2.git_blob_create_from_workdir(
|
||||
out,
|
||||
repoPointer,
|
||||
|
@ -110,7 +111,7 @@ Pointer<git_oid> createFromDisk({
|
|||
required String path,
|
||||
}) {
|
||||
final out = calloc<git_oid>();
|
||||
final pathC = path.toNativeUtf8().cast<Char>();
|
||||
final pathC = path.toChar();
|
||||
final error = libgit2.git_blob_create_from_disk(out, repoPointer, pathC);
|
||||
|
||||
calloc.free(pathC);
|
||||
|
@ -150,7 +151,7 @@ String filterContent({
|
|||
git_oid? attributesCommit,
|
||||
}) {
|
||||
final out = calloc<git_buf>();
|
||||
final asPathC = asPath.toNativeUtf8().cast<Char>();
|
||||
final asPathC = asPath.toChar();
|
||||
final opts = calloc<git_blob_filter_options>();
|
||||
libgit2.git_blob_filter_options_init(opts, GIT_BLOB_FILTER_OPTIONS_VERSION);
|
||||
opts.ref.flags = flags;
|
||||
|
@ -162,7 +163,7 @@ String filterContent({
|
|||
|
||||
late final String result;
|
||||
if (out.ref.ptr != nullptr) {
|
||||
result = out.ref.ptr.cast<Utf8>().toDartString(length: out.ref.size);
|
||||
result = out.ref.ptr.toDartString(length: out.ref.size);
|
||||
}
|
||||
|
||||
libgit2.git_buf_dispose(out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue