mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-23 03:39:26 +01:00
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
|
|
using Flowframes.Data;
|
|||
|
|
using Flowframes.Forms;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace Flowframes.IO
|
|||
|
|
{
|
|||
|
|
class PkgUtils
|
|||
|
|
{
|
|||
|
|
public static FlowPackage GetPkg(string friendlyNameOrFilename)
|
|||
|
|
{
|
|||
|
|
foreach (FlowPackage pkg in PkgInstaller.packages)
|
|||
|
|
{
|
|||
|
|
if (pkg.fileName == friendlyNameOrFilename)
|
|||
|
|
return pkg;
|
|||
|
|
if (pkg.friendlyName == friendlyNameOrFilename)
|
|||
|
|
return pkg;
|
|||
|
|
}
|
|||
|
|
return new FlowPackage();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static string GetPkgFolder (FlowPackage pkg)
|
|||
|
|
{
|
|||
|
|
return Path.Combine(Paths.GetPkgPath(), Path.GetFileNameWithoutExtension(pkg.fileName));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static bool IsInstalled(FlowPackage pkg)
|
|||
|
|
{
|
|||
|
|
string path = GetPkgFolder(pkg);
|
|||
|
|
return (Directory.Exists(path) && IOUtils.GetAmountOfFiles(path, true) > 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static bool IsUpToDate(FlowPackage pkg, int minVersion)
|
|||
|
|
{
|
|||
|
|
return (GetVersion(pkg) >= minVersion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static int GetVersion (FlowPackage pkg)
|
|||
|
|
{
|
|||
|
|
string versionFilePath = Path.Combine(GetPkgFolder(pkg), "ver.ini");
|
|||
|
|
return IOUtils.ReadLines(versionFilePath)[0].Split('#')[0].GetInt();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static bool IsAiAvailable(AI ai, bool msg = true)
|
|||
|
|
{
|
|||
|
|
Logger.Log("PkgInstaller.IsAiAvailable - Checking for AI " + ai.aiName, true);
|
|||
|
|
return IsInstalled(ai.pkg);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|