From ea6c8d31583a9c769c463dfdb76c55b0cc92af1c Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 26 Nov 2018 17:05:42 -0800 Subject: [PATCH] Track modification for single file edits --- pkNX.Containers/SingleFileContainer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkNX.Containers/SingleFileContainer.cs b/pkNX.Containers/SingleFileContainer.cs index 9b967266..930975f3 100644 --- a/pkNX.Containers/SingleFileContainer.cs +++ b/pkNX.Containers/SingleFileContainer.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -24,7 +25,16 @@ public void CancelEdits() Data = (byte[]) Backup.Clone(); } - public byte[] this[int index] { get => Data; set => Data = value; } + public byte[] this[int index] + { + get => (byte[])Data.Clone(); + set + { + Modified |= Data.SequenceEqual(value); + Data = value; + } + } + public Task GetFiles() => Task.FromResult(new[] {Data}); public Task GetFile(int file, int subFile = 0) => Task.FromResult(Data); public Task SetFile(int file, byte[] value, int subFile = 0) => Task.FromResult(Data = value);