Skip to content

Commit

Permalink
Proper stream usage + simpler archive open
Browse files Browse the repository at this point in the history
  • Loading branch information
indilo53 committed Apr 27, 2019
1 parent 84881eb commit 9ca3afd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 2 additions & 8 deletions RageLib.GTA5/ArchiveWrappers/RageArchiveWrapper7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,8 @@ public void Import(Stream stream)
{
var binaryStream = GetStream();
binaryStream.SetLength(stream.Length);

byte[] buf = new byte[stream.Length];
stream.Position = 0;
stream.Read(buf, 0, buf.Length);
binaryStream.Write(buf, 0, buf.Length);
stream.CopyTo(binaryStream);
}

/// <summary>
Expand All @@ -702,10 +699,7 @@ public void Export(string fileName)
public void Export(Stream stream)
{
var binaryStream = GetStream();

var buf = new byte[binaryStream.Length];
binaryStream.Read(buf, 0, buf.Length);
stream.Write(buf, 0, buf.Length);
binaryStream.CopyTo(stream);
}
}

Expand Down
5 changes: 1 addition & 4 deletions RageLib.GTA5/Utilities/ArchiveUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ public static void ForEachFile(string gameDirectoryName, ProcessFileDelegate pro
try
{
var fileName = archiveFileNames[i];
var fileInfo = new FileInfo(fileName);
var fileStream = new FileStream(fileName, FileMode.Open);

var inputArchive = RageArchiveWrapper7.Open(fileStream, fileInfo.Name);
var inputArchive = RageArchiveWrapper7.Open(fileName);
ForEachFile(fileName.Replace(gameDirectoryName, ""), inputArchive.Root, inputArchive.archive_.Encryption, processDelegate);
inputArchive.Dispose();
}
Expand Down

0 comments on commit 9ca3afd

Please sign in to comment.