Fix not updating files

Returning bool and using object, might as well play it safe.
This commit is contained in:
Kurt
2015-07-03 00:20:03 -07:00
parent 4b3e60e490
commit c6ed582882

View File

@@ -313,12 +313,12 @@ internal static int getDARCposition(byte[] data)
{ pos += 4; if (pos >= data.Length) return -1; }
return pos;
}
internal static bool insertFile(DARC orig, int index, string path)
internal static bool insertFile(ref DARC orig, int index, string path)
{
try { return insertFile(orig, index, File.ReadAllBytes(path)); }
try { return insertFile(ref orig, index, File.ReadAllBytes(path)); }
catch (Exception) { return false; }
}
internal static bool insertFile(DARC orig, int index, byte[] data)
internal static bool insertFile(ref DARC orig, int index, byte[] data)
{
if (index < 0) return false;
@@ -359,7 +359,7 @@ internal static DARC insertFiles(DARC orig, string folderName)
if (orig.Entries[index].IsFolder)
throw new Exception(file + " is not a valid file to reinsert!");
insertFile(orig, index, file);
insertFile(ref orig, index, file);
}
// Fix Data layout
Array.Resize(ref orig.Data, orig.Data.Length % 4 == 0 ? orig.Data.Length : orig.Data.Length + 4 - orig.Data.Length % 4);