Skip to content

Commit

Permalink
revert DirectoryRecord
Browse files Browse the repository at this point in the history
added zh-cn locale detect
  • Loading branch information
Chuanhsing committed Sep 26, 2020
1 parent 9a6a09a commit a75b43e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions LibGGPK/Records/DirectoryRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public override void Write(BinaryWriter bw, Dictionary<long, long> changedOffset
/// <param name="ggpkPath">Path of pack file that contains this record</param>
/// <param name="nameHash">Previous name hash of entry</param>
/// <param name="newEntryOffset">New offset of entry</param>
public void UpdateOffset(FileStream ggpkFileStream, uint nameHash, long newEntryOffset)
public void UpdateOffset(string ggpkPath, uint nameHash, long newEntryOffset)
{
var entry = Entries.FirstOrDefault(e => e.EntryNameHash == nameHash);
if (entry.Offset == 0 )
throw new ApplicationException("Entry not found!");

//using (var ggpkFileStream = File.Open(ggpkPath, FileMode.Open))
using (var ggpkFileStream = File.Open(ggpkPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
{
// Jump to the location of 'Entries' in the ggpk file and
// change the entry for 'previousEntryOffset' to 'newEntryOffset'
Expand Down
3 changes: 1 addition & 2 deletions LibGGPK/Records/FileRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ public void ReplaceContents(string ggpkPath, byte[] replacmentData, LinkedList<F
Length = (uint)(Length - DataLength + replacmentData.Length);
if (ggpc != null)
ggpc.RecordOffsets[RecordBegin] = this;
ContainingDirectory.Record.UpdateOffset(ggpkFileStream, GetNameHash(), RecordBegin);
ggpkFileStream.Seek(0, SeekOrigin.End);
ContainingDirectory.Record.UpdateOffset(ggpkPath, GetNameHash(), RecordBegin);
} else
{
ggpkFileStream.Seek(RecordBegin, SeekOrigin.Begin);
Expand Down
12 changes: 11 additions & 1 deletion VPatchGGPK/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,25 @@ public Form1()
OutputLine(ggpkPath);
}

lang = "tw";
if (CultureInfo.CurrentCulture.Name.Equals("zh-TW"))
{
labelContentGGPKPath.Text = "Content.ggpk 路徑";
buttonSelectPOE.Text = "選擇 POE";
buttonApplyZIP.Text = "套用 ZIP";
buttonClose.Text = "關閉";
buttonApplyChinese.Text = "套用中文化";
lang = "tw";
} else if (CultureInfo.CurrentCulture.Name.Equals("zh-CN"))
{
labelContentGGPKPath.Text = "Content.ggpk 路径";
buttonSelectPOE.Text = "选择 POE";
buttonApplyZIP.Text = "套用 ZIP";
buttonClose.Text = "关闭";
buttonApplyChinese.Text = "套用中文化";
lang = "cn";
radioButtonCN.Checked = true;
}
lang = "tw";
patch_md5 = "";
}

Expand Down

0 comments on commit a75b43e

Please sign in to comment.