checkpoint

This commit is contained in:
2020-04-30 13:33:30 -04:00
parent 19a9fc06ba
commit 9bc522180d
21 changed files with 337 additions and 276 deletions

View File

@@ -19,20 +19,11 @@ namespace Foodsoft.Alpm
public bool RemoveServer(string url) =>
API.WrapErrorBool(_handle.SafeAlpmHandle, () => alpm.alpm_db_remove_server(_handle, url));
private readonly struct ServersImpl : ICollectionImpl<string>
{
private readonly SafeDatabaseHandle _handle;
internal ServersImpl(SafeDatabaseHandle handle) => _handle = handle;
public SafeHandle Handle => _handle;
public IntPtr GetItems() => alpm.alpm_db_get_servers(_handle);
public string PtrToItem(IntPtr p) => Marshal.PtrToStringUTF8(p)!;
}
// FIXME: This is "bug correct", but probably dumb to do it this way, instead just call add_server
// like all the stuff in handle.
public IEnumerable<string> Servers
{
get => EnumerableWrapper<string>.Create(new ServersImpl(_handle));
get => EnumerableWrapper.Create(_handle, alpm.alpm_db_get_servers);
set
{
var listPtr = IntPtr.Zero;
@@ -94,14 +85,14 @@ namespace Foodsoft.Alpm
return new CachePackage(new SafeCachePackageHandle(pkgPtr, _handle), this);
}
public PackageList PackageCache
public CachePackageList CachePackageCache
{
get
{
var listPtr = alpm.alpm_db_get_pkgcache(_handle);
if (listPtr == IntPtr.Zero)
throw new AlpmException(_handle.SafeAlpmHandle);
return new PackageList(listPtr, _handle, this);
return new CachePackageList(listPtr, _handle, this);
}
}