blob: 9b6853b4eaa2011a74595873fa05ab5f612fa463 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
using System.Collections.Generic;
using System.IO;
using System.Linq;
using StardewModdingAPI.Toolkit.Serialisation.Models;
namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{
/// <summary>The info about a mod read from its folder.</summary>
public class ModFolder
{
/*********
** Accessors
*********/
/// <summary>The Mods subfolder containing this mod.</summary>
public DirectoryInfo SearchDirectory { get; }
/// <summary>The folder containing manifest.json.</summary>
public DirectoryInfo ActualDirectory { get; }
/// <summary>The mod manifest.</summary>
public Manifest Manifest { get; }
/// <summary>The error which occurred parsing the manifest, if any.</summary>
public string ManifestParseError { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance when a mod wasn't found in a folder.</summary>
/// <param name="searchDirectory">The directory that was searched.</param>
public ModFolder(DirectoryInfo searchDirectory)
{
this.SearchDirectory = searchDirectory;
}
/// <summary>Construct an instance.</summary>
/// <param name="searchDirectory">The Mods subfolder containing this mod.</param>
/// <param name="actualDirectory">The folder containing manifest.json.</param>
/// <param name="manifest">The mod manifest.</param>
/// <param name="manifestParseError">The error which occurred parsing the manifest, if any.</param>
public ModFolder(DirectoryInfo searchDirectory, DirectoryInfo actualDirectory, Manifest manifest, string manifestParseError = null)
{
this.SearchDirectory = searchDirectory;
this.ActualDirectory = actualDirectory;
this.Manifest = manifest;
this.ManifestParseError = manifestParseError;
}
/// <summary>Get the update keys for a mod.</summary>
/// <param name="manifest">The mod manifest.</param>
public IEnumerable<string> GetUpdateKeys(Manifest manifest)
{
return
(manifest.UpdateKeys ?? new string[0])
.Where(p => !string.IsNullOrWhiteSpace(p))
.ToArray();
}
}
}
|