edge-install/Version/Version.IComparable.cs
Robert Morrison 60e06b2144
Another bad commit
Lots of changes here...

- Removed code using RecursivExtractor due to bad usage of /tmp
  Note: the code that used RecursiveExtractor may not have been in the
  previous commit
- Created _functioning_ implementation of DebUnpacker
- Restructured Project layout.

TODO:
- Possibly rewrite how the DebUnpacker works to have the file contents
  part of an entry.
- Further restructuring and refactoring to make the code a little
  neater.
- Add code for the final unpack steps Un-XZ -> untar -> write to disk
- Add code to install
- Add code for modified post-install pre-remove etc..
  This is kinda needed to ensure proper system integration of new
  packages.
2023-06-08 04:36:31 +01:00

76 lines
1.8 KiB
C#

namespace EdgeInstaller;
public sealed partial class Version : IComparable<Version>
{
public int CompareTo(Version? other)
{
if (other is null)
{
return 1;
}
// full Equality is easy since everything should be the same.
// OPTIM: Doing this here is techinally more effecient than baking it in to the later code
// Bools and shit
if (this.Major == other.Major &&
this.Minor == other.Minor &&
this.Build == other.Build &&
this.Patch == other.Patch &&
this.Subpatch == other.Subpatch)
{
return 0;
}
// Compare major version
if (Major != other.Major)
return Major.CompareTo(other.Major);
// Compare minor version
if (Minor != other.Minor)
return Minor.CompareTo(other.Minor);
// Compare build number
if (Build != other.Build)
return Build.CompareTo(other.Build);
// Compare patch number
if (Patch != other.Patch)
return Patch.CompareTo(other.Patch);
// Compare subpatch number
return Subpatch.CompareTo(other.Subpatch);
}
public bool Equals(Version? other)
{
if (other is null)
{
return false;
}
return this.CompareTo(other) == 0;
}
public static bool operator >(Version v1, Version v2)
{
return v1.CompareTo(v2) > 0;
}
public static bool operator <(Version v1, Version v2)
{
return v1.CompareTo(v2) < 0;
}
public static bool operator >=(Version v1, Version v2)
{
return v1.CompareTo(v2) >= 0;
}
public static bool operator <=(Version v1, Version v2)
{
return v1.CompareTo(v2) <= 0;
}
}