checkpoint

This commit is contained in:
2020-04-30 20:40:52 -04:00
parent 9aa367e9f5
commit abba062f4f
28 changed files with 615 additions and 544 deletions

View File

@@ -19,12 +19,13 @@ namespace Foodsoft.Alpm
public File? Contains(string path)
{
return _handle.UseHandle(_ptr, (ptr) =>
return _handle.UseHandle(_ptr, ptr =>
{
var foundPtr = alpm.alpm_filelist_contains(ptr, path);
return foundPtr != IntPtr.Zero ? new File(foundPtr) : (File?) null;
});
}
public IEnumerator<File> GetEnumerator()
{
var release = false;
@@ -35,10 +36,7 @@ namespace Foodsoft.Alpm
_handle.DangerousAddRef(ref release);
if (!release) throw new ObjectDisposedException(_handle.GetType().FullName);
var arrayPtr = FileArray(_ptr, out var count);
for (var i = 0; i < count; ++i)
{
yield return new File(FilePtr(arrayPtr, i));
}
for (var i = 0; i < count; ++i) yield return new File(FilePtr(arrayPtr, i));
}
finally
{
@@ -58,7 +56,7 @@ namespace Foodsoft.Alpm
{
get
{
return _handle.UseHandle(_ptr, (ptr) =>
return _handle.UseHandle(_ptr, ptr =>
{
var arrayPtr = FileArray(ptr, out var count);
if (index >= count || index < 0)
@@ -67,8 +65,8 @@ namespace Foodsoft.Alpm
});
}
}
[StructLayout(LayoutKind.Sequential)]
private readonly unsafe struct NativeFileList
{