diff --git a/Penumbra/Collections/ModCollection.Cache.Access.cs b/Penumbra/Collections/ModCollection.Cache.Access.cs index 8c2bddd3..332c7f81 100644 --- a/Penumbra/Collections/ModCollection.Cache.Access.cs +++ b/Penumbra/Collections/ModCollection.Cache.Access.cs @@ -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 ) diff --git a/Penumbra/Collections/ModCollection.Cache.cs b/Penumbra/Collections/ModCollection.Cache.cs index c329b3de..c525edd1 100644 --- a/Penumbra/Collections/ModCollection.Cache.cs +++ b/Penumbra/Collections/ModCollection.Cache.cs @@ -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;