Check for too long paths when building cache.

This commit is contained in:
Ottermandias 2022-08-15 12:57:57 +02:00
parent 5e9cb77415
commit df9f791395
2 changed files with 23 additions and 1 deletions

View file

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using Dalamud.Logging;
using OtterGui.Classes;
@ -70,7 +72,24 @@ public partial class ModCollection
// Force a file to be resolved to a specific path regardless of conflicts.
internal void ForceFile( Utf8GamePath path, FullPath fullPath )
=> _cache!.ResolvedFiles[ path ] = new ModPath( Mod.ForcedFiles, fullPath );
{
if( CheckFullPath( path, fullPath ) )
{
_cache!.ResolvedFiles[ path ] = new ModPath( Mod.ForcedFiles, fullPath );
}
}
[MethodImpl( MethodImplOptions.AggressiveInlining )]
private static bool CheckFullPath( Utf8GamePath path, FullPath fullPath )
{
if( fullPath.InternalName.Length < Utf8GamePath.MaxGamePathLength )
{
return true;
}
PluginLog.Error( $"Could not add the redirection {path} to {fullPath}, the redirected path is too long." );
return false;
}
// Force a file resolve to be removed.
internal void RemoveFile( Utf8GamePath path )

View file

@ -326,6 +326,9 @@ public partial class ModCollection
// Inside the same mod, conflicts are not recorded.
private void AddFile( Utf8GamePath path, FullPath file, IMod mod )
{
if (!CheckFullPath( path, file ))
return;
if( ResolvedFiles.TryAdd( path, new ModPath( mod, file ) ) )
{
return;