mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
fix: random file paths in ttmps
This commit is contained in:
parent
53105a4653
commit
54902f78be
1 changed files with 23 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -63,12 +64,28 @@ namespace Penumbra.Importer
|
||||||
fs.Close();
|
fs.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// You can in no way rely on any file paths in TTMPs so we need to just do this, sorry
|
||||||
|
private ZipEntry FindZipEntry( ZipFile file, string fileName )
|
||||||
|
{
|
||||||
|
for( var i = 0; i < file.Count; i++ )
|
||||||
|
{
|
||||||
|
var entry = file[ i ];
|
||||||
|
|
||||||
|
if( entry.Name.Contains( fileName ) )
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private PenumbraSqPackStream GetMagicSqPackDeleterStream( ZipFile file, string entryName )
|
private PenumbraSqPackStream GetMagicSqPackDeleterStream( ZipFile file, string entryName )
|
||||||
{
|
{
|
||||||
State = ImporterState.WritingPackToDisk;
|
State = ImporterState.WritingPackToDisk;
|
||||||
|
|
||||||
// write shitty zip garbage to disk
|
// write shitty zip garbage to disk
|
||||||
var entry = file.GetEntry( entryName );
|
var entry = FindZipEntry( file, entryName );
|
||||||
|
Debug.Assert( entry != null, $"Could not find in mod zip: {entryName}" );
|
||||||
|
|
||||||
using var s = file.GetInputStream( entry );
|
using var s = file.GetInputStream( entry );
|
||||||
|
|
||||||
WriteZipEntryToTempFile( s );
|
WriteZipEntryToTempFile( s );
|
||||||
|
|
@ -81,8 +98,11 @@ namespace Penumbra.Importer
|
||||||
{
|
{
|
||||||
using var zfs = modPackFile.OpenRead();
|
using var zfs = modPackFile.OpenRead();
|
||||||
using var extractedModPack = new ZipFile( zfs );
|
using var extractedModPack = new ZipFile( zfs );
|
||||||
var mpl = extractedModPack.GetEntry( "TTMPL.mpl" );
|
|
||||||
var modRaw = GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 );
|
var mpl = FindZipEntry( extractedModPack, "TTMPL.mpl" );
|
||||||
|
Debug.Assert( mpl != null, "Could not find mod meta in ZIP." );
|
||||||
|
|
||||||
|
var modRaw = GetStringFromZipEntry( extractedModPack, mpl, Encoding.UTF8 );
|
||||||
|
|
||||||
// At least a better validation than going by the extension.
|
// At least a better validation than going by the extension.
|
||||||
if( modRaw.Contains( "\"TTMPVersion\":" ) )
|
if( modRaw.Contains( "\"TTMPVersion\":" ) )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue