mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-20 14:57:50 +01:00
Sanity check ShPk mods, ban incompatible ones
This commit is contained in:
parent
700fef4f04
commit
dba85f5da3
3 changed files with 159 additions and 0 deletions
|
|
@ -350,4 +350,22 @@ public sealed class ModManager : ModStorage, IDisposable, IService
|
|||
Penumbra.Log.Error($"Could not scan for mods:\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryIdentifyPath(string path, [NotNullWhen(true)] out Mod? mod, [NotNullWhen(true)] out string? relativePath)
|
||||
{
|
||||
var relPath = Path.GetRelativePath(BasePath.FullName, path);
|
||||
if (relPath != "." && (relPath.StartsWith('.') || Path.IsPathRooted(relPath)))
|
||||
{
|
||||
mod = null;
|
||||
relativePath = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var modDirectorySeparator = relPath.IndexOfAny([Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar]);
|
||||
|
||||
var modDirectory = modDirectorySeparator < 0 ? relPath : relPath[..modDirectorySeparator];
|
||||
relativePath = modDirectorySeparator < 0 ? string.Empty : relPath[(modDirectorySeparator + 1)..];
|
||||
|
||||
return TryGetMod(modDirectory, "\0", out mod);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue