Files
DotNetAlpm/Alpm/Package.cs
2020-04-29 23:47:06 -04:00

79 lines
2.9 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 =>
EnumerableWrapperEx<string>.Create(Handle, alpm.alpm_pkg_get_licenses, Marshal.PtrToStringUTF8!);
public ICollection<string> Groups { get; }
public ICollection<Depend> Depends { get; }
public ICollection<Depend> OptDepends { get; }
public ICollection<Depend> CheckDepends { get; }
public ICollection<Depend> MakeDepends { get; }
public ICollection<Depend> Conflicts { get; }
public ICollection<Depend> Provides { get; }
public ICollection<Depend> Replaces { get; }
public IReadOnlyList<File> FileList { get; }
public IReadOnlyList<Backup> Backup { get; }
public string Base64Signature { get; }
public ValidationType Validation { get; }
public bool HasScriptlet { get; }
public long DownloadSize { get; }
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);
}
}
}