Fixed broken patching and endless Steam nags introduced in SMM 1.7

This commit is contained in:
Vhati 2017-12-12 07:38:17 -05:00
parent cefb4986c0
commit a2bd02123e
7 changed files with 28 additions and 16 deletions

View file

@ -566,6 +566,9 @@ public class PkgPack extends AbstractPack {
return result;
}
/**
* Adds bytes read from an InputStream to the pack, as innerPath.
*/
@Override
public void add( String innerPath, InputStream is ) throws IOException {
if ( innerPath.indexOf( "\\" ) != -1 ) {
@ -608,19 +611,18 @@ public class PkgPack extends AbstractPack {
}
// Write data.
try {
raf.seek( entry.dataOffset );
byte[] buf = new byte[4096];
int len;
while ( (len = dataStream.read( buf )) >= 0 ) {
raf.write( buf, 0, len );
}
}
finally {
try {if ( dataStream != null ) dataStream.close();}
catch ( IOException e ) {}
raf.seek( entry.dataOffset );
byte[] buf = new byte[4096];
int len;
while ( (len = dataStream.read( buf )) >= 0 ) {
raf.write( buf, 0, len );
}
// Attempting to close the wrapper streams would cause an exception if
// the original stream was a ZipInputStream, which would need closeEntry().
// TODO: Test if compression works without closing the wrapper.
// Go back and fill in the dataSize.
entry.dataSize = raf.getChannel().position() - entry.dataOffset;
entry.unpackedSize = srcMeterStream.getCount();