Files
DotNetAlpm/Alpm/Package.cs
2020-04-30 13:33:30 -04:00

80 lines
3.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Foodsoft.Alpm
{
public abstract class Package : IPackageData
{
internal SafePackageHandle Handle { get; }
internal Package(SafePackageHandle handle)
{
Handle = handle;
}
public string Filename => alpm.alpm_pkg_get_filename(Handle);
public string Base => alpm.alpm_pkg_get_base(Handle);
public string Name => alpm.alpm_pkg_get_name(Handle);
public string Version => alpm.alpm_pkg_get_version(Handle);
public PackageOrigin Origin => alpm.alpm_pkg_get_origin(Handle);
public string Description => alpm.alpm_pkg_get_desc(Handle);
public string Url => alpm.alpm_pkg_get_url(Handle);
public DateTimeOffset BuildDate => DateTimeOffset.FromUnixTimeSeconds(alpm.alpm_pkg_get_builddate(Handle));
public DateTimeOffset InstallDate => DateTimeOffset.FromUnixTimeSeconds(alpm.alpm_pkg_get_installdate(Handle));
public string Packager => alpm.alpm_pkg_get_packager(Handle);
public string MD5Sum => alpm.alpm_pkg_get_md5sum(Handle);
public string SHA256Sum => alpm.alpm_pkg_get_sha256sum(Handle);
public string Arch => alpm.alpm_pkg_get_arch(Handle);
public long Size => alpm.alpm_pkg_get_size(Handle);
public long InstalledSize => alpm.alpm_pkg_get_isize(Handle);
public InstallReason InstallReason => alpm.alpm_pkg_get_reason(Handle);
public ICollection<string> Licenses =>
EnumerableWrapper.Create(Handle, alpm.alpm_pkg_get_licenses);
public ICollection<string> Groups => EnumerableWrapper.Create(Handle, alpm.alpm_pkg_get_groups);
public ICollection<Depend> Depends => EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_depends);
public ICollection<Depend> OptDepends =>
EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_optdepends);
public ICollection<Depend> CheckDepends =>
EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_checkdepends);
public ICollection<Depend> MakeDepends =>
EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_makedepends);
public ICollection<Depend> Conflicts => EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_conflicts);
public ICollection<Depend> Provides => EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_provides);
public ICollection<Depend> Replaces => EnumerableWrapper.CreateForDepend(Handle, alpm.alpm_pkg_get_replaces);
public IReadOnlyList<File> Files => new FileList(Handle, alpm.alpm_pkg_get_files(Handle));
public ICollection<Backup> Backup => EnumerableWrapper.CreateForBackup(Handle, alpm.alpm_pkg_get_backup);
public string Base64Signature => alpm.alpm_pkg_get_base64_sig(Handle);
public ValidationType Validation => alpm.alpm_pkg_get_validation(Handle);
public bool HasScriptlet => alpm.alpm_pkg_has_scriptlet(Handle);
public long DownloadSize => alpm.alpm_pkg_download_size(Handle);
public bool CheckMD5Sum()
{
throw new NotImplementedException();
}
public virtual Database? DB => null;
public IEnumerator<Package> ComputeRequiredBy()
{
throw new NotImplementedException();
}
public IEnumerator<Package> ComputeOptionalFor()
{
throw new NotImplementedException();
}
public void Dispose()
{
Handle.Dispose();
}
public static int VersionCompare(string v1, string v2)
{
return alpm.alpm_pkg_vercmp(v1, v2);
}
}
}