diff --git a/AAMod/ModMainForm.cs b/AAMod/ModMainForm.cs index 315896e..bb20dbf 100644 --- a/AAMod/ModMainForm.cs +++ b/AAMod/ModMainForm.cs @@ -354,7 +354,7 @@ private void BtnInstall_Click(object sender, EventArgs e) var fileBackupStream = gamepak.ExportFileAsStream(fi.name); fileBackupStream.Position = 0; AAPakFileInfo restoreFileInfo = restorepak.nullAAPakFileInfo; - if (!restorepak.AddFileFromStream(fi.name, fileBackupStream, DateTime.FromFileTime(gamefi.createTime), DateTime.FromFileTime(gamefi.modifyTime), false, out restoreFileInfo)) + if (!restorepak.AddFileFromStream(fi.name, fileBackupStream, DateTime.FromFileTimeUtc(gamefi.createTime), DateTime.FromFileTimeUtc(gamefi.modifyTime), false, out restoreFileInfo)) { MessageBox.Show("Error making backup of " + fi.name); } @@ -363,7 +363,7 @@ private void BtnInstall_Click(object sender, EventArgs e) var fileModStream = modpak.ExportFileAsStream(fi.name); fileModStream.Position = 0; AAPakFileInfo newModFile = gamepak.nullAAPakFileInfo; - if (!gamepak.AddFileFromStream(fi.name, fileModStream, DateTime.FromFileTime(fi.createTime), DateTime.FromFileTime(fi.modifyTime), false, out newModFile)) + if (!gamepak.AddFileFromStream(fi.name, fileModStream, DateTime.FromFileTimeUtc(fi.createTime), DateTime.FromFileTimeUtc(fi.modifyTime), false, out newModFile)) { MessageBox.Show("Error modding file " + fi.name); } @@ -417,7 +417,7 @@ private void BtnUninstall_Click(object sender, EventArgs e) var fileRestoreStream = restorepak.ExportFileAsStream(fi.name); fileRestoreStream.Position = 0; AAPakFileInfo restoreFileInfo = gamepak.nullAAPakFileInfo; - if (!gamepak.AddFileFromStream(fi.name, fileRestoreStream, DateTime.FromFileTime(rfi.createTime), DateTime.FromFileTime(rfi.modifyTime), false, out restoreFileInfo)) + if (!gamepak.AddFileFromStream(fi.name, fileRestoreStream, DateTime.FromFileTimeUtc(rfi.createTime), DateTime.FromFileTimeUtc(rfi.modifyTime), false, out restoreFileInfo)) { MessageBox.Show("Error restoring file " + fi.name); } diff --git a/AAPakCLI/Program.cs b/AAPakCLI/Program.cs index 8f3650c..2d9596d 100644 --- a/AAPakCLI/Program.cs +++ b/AAPakCLI/Program.cs @@ -118,7 +118,7 @@ static private void CreateCSVFile(ref AAPak pak, string filename = "") sl.Add(s); foreach (AAPakFileInfo pfi in pak.files) { - DateTime modTime = DateTime.FromFileTime(pfi.modifyTime); + DateTime modTime = DateTime.FromFileTimeUtc(pfi.modifyTime); if (modTime > newest) newest = modTime; @@ -126,7 +126,7 @@ static private void CreateCSVFile(ref AAPak pak, string filename = "") s += ";" + pfi.size.ToString(); s += ";" + pfi.offset.ToString(); s += ";" + BitConverter.ToString(pfi.md5).Replace("-", "").ToUpper(); - s += ";" + AAPak.DateTimeToDateTimeStr(DateTime.FromFileTime(pfi.createTime));// DateTimeToDateTimeStr DateTime.FromFileTime(pfi.createTime).ToString("yyyy-MM-dd HH:mm:ss"); + s += ";" + AAPak.DateTimeToDateTimeStr(DateTime.FromFileTimeUtc(pfi.createTime));// DateTimeToDateTimeStr DateTime.FromFileTimeUtc(pfi.createTime).ToString("yyyy-MM-dd HH:mm:ss"); s += ";" + AAPak.DateTimeToDateTimeStr(modTime); // .ToString("yyyy-MM-dd HH:mm:ss"); s += ";" + pfi.sizeDuplicate.ToString(); s += ";" + pfi.paddingSize.ToString(); diff --git a/AAPakEditor/ExportAllDlg.cs b/AAPakEditor/ExportAllDlg.cs index cdc0397..179d9e5 100644 --- a/AAPakEditor/ExportAllDlg.cs +++ b/AAPakEditor/ExportAllDlg.cs @@ -50,8 +50,8 @@ public bool ExportFile(AAPakFileInfo pfi, string destName) fs.Dispose(); // Update file details - File.SetCreationTime(destName, DateTime.FromFileTime(pfi.createTime)); - File.SetLastWriteTime(destName, DateTime.FromFileTime(pfi.modifyTime)); + File.SetCreationTime(destName, DateTime.FromFileTimeUtc(pfi.createTime)); + File.SetLastWriteTime(destName, DateTime.FromFileTimeUtc(pfi.modifyTime)); } catch { diff --git a/AAPakEditor/FilePropForm.Designer.cs b/AAPakEditor/FilePropForm.Designer.cs index 662400b..e33e42a 100644 --- a/AAPakEditor/FilePropForm.Designer.cs +++ b/AAPakEditor/FilePropForm.Designer.cs @@ -53,6 +53,10 @@ private void InitializeComponent() this.lPadding = new System.Windows.Forms.Label(); this.lWarning = new System.Windows.Forms.Label(); this.tWarnings = new System.Windows.Forms.TextBox(); + this.tCreateAsNumber = new System.Windows.Forms.TextBox(); + this.tModifyAsNumber = new System.Windows.Forms.TextBox(); + this.lCTtoR = new System.Windows.Forms.Label(); + this.lDTToR = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lfiIndex @@ -158,7 +162,7 @@ private void InitializeComponent() this.dtCreate.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtCreate.Location = new System.Drawing.Point(91, 138); this.dtCreate.Name = "dtCreate"; - this.dtCreate.Size = new System.Drawing.Size(200, 20); + this.dtCreate.Size = new System.Drawing.Size(190, 20); this.dtCreate.TabIndex = 11; this.dtCreate.ValueChanged += new System.EventHandler(this.tFieldsChanged); // @@ -168,7 +172,7 @@ private void InitializeComponent() this.dtModified.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtModified.Location = new System.Drawing.Point(91, 164); this.dtModified.Name = "dtModified"; - this.dtModified.Size = new System.Drawing.Size(200, 20); + this.dtModified.Size = new System.Drawing.Size(190, 20); this.dtModified.TabIndex = 12; this.dtModified.ValueChanged += new System.EventHandler(this.tFieldsChanged); // @@ -281,11 +285,53 @@ private void InitializeComponent() this.tWarnings.Size = new System.Drawing.Size(433, 57); this.tWarnings.TabIndex = 24; // + // tCreateAsNumber + // + this.tCreateAsNumber.Location = new System.Drawing.Point(322, 138); + this.tCreateAsNumber.Name = "tCreateAsNumber"; + this.tCreateAsNumber.Size = new System.Drawing.Size(126, 20); + this.tCreateAsNumber.TabIndex = 25; + this.tCreateAsNumber.TextChanged += new System.EventHandler(this.tFieldsChanged); + // + // tModifyAsNumber + // + this.tModifyAsNumber.Location = new System.Drawing.Point(322, 164); + this.tModifyAsNumber.Name = "tModifyAsNumber"; + this.tModifyAsNumber.Size = new System.Drawing.Size(126, 20); + this.tModifyAsNumber.TabIndex = 26; + this.tModifyAsNumber.TextChanged += new System.EventHandler(this.tFieldsChanged); + // + // lCTtoR + // + this.lCTtoR.AutoSize = true; + this.lCTtoR.Cursor = System.Windows.Forms.Cursors.Hand; + this.lCTtoR.Location = new System.Drawing.Point(297, 138); + this.lCTtoR.Name = "lCTtoR"; + this.lCTtoR.Size = new System.Drawing.Size(19, 13); + this.lCTtoR.TabIndex = 27; + this.lCTtoR.Text = "=>"; + this.lCTtoR.Click += new System.EventHandler(this.lCTtoR_Click); + // + // lDTToR + // + this.lDTToR.AutoSize = true; + this.lDTToR.Cursor = System.Windows.Forms.Cursors.Hand; + this.lDTToR.Location = new System.Drawing.Point(297, 167); + this.lDTToR.Name = "lDTToR"; + this.lDTToR.Size = new System.Drawing.Size(19, 13); + this.lDTToR.TabIndex = 28; + this.lDTToR.Text = "=>"; + this.lDTToR.Click += new System.EventHandler(this.lDTToR_Click); + // // FilePropForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(465, 388); + this.Controls.Add(this.lDTToR); + this.Controls.Add(this.lCTtoR); + this.Controls.Add(this.tModifyAsNumber); + this.Controls.Add(this.tCreateAsNumber); this.Controls.Add(this.tWarnings); this.Controls.Add(this.lWarning); this.Controls.Add(this.tPaddingSize); @@ -349,5 +395,9 @@ private void InitializeComponent() private System.Windows.Forms.Label lPadding; private System.Windows.Forms.Label lWarning; private System.Windows.Forms.TextBox tWarnings; + private System.Windows.Forms.TextBox tCreateAsNumber; + private System.Windows.Forms.TextBox tModifyAsNumber; + private System.Windows.Forms.Label lCTtoR; + private System.Windows.Forms.Label lDTToR; } } \ No newline at end of file diff --git a/AAPakEditor/FilePropForm.cs b/AAPakEditor/FilePropForm.cs index 807b2bf..5008934 100644 --- a/AAPakEditor/FilePropForm.cs +++ b/AAPakEditor/FilePropForm.cs @@ -250,10 +250,27 @@ public void ResetFileInfo() tHash.Text = BitConverter.ToString(pfi.md5).ToUpper().Replace("-", ""); - dtCreate.Value = DateTime.FromFileTime(pfi.createTime); - if (pfi.modifyTime != 0) - dtModified.Value = DateTime.FromFileTime(pfi.modifyTime); - dtModified.Value = DateTime.UtcNow ; + dtCreate.Value = DateTime.UtcNow; + dtModified.Value = DateTime.UtcNow; + try + { + dtCreate.Value = DateTime.FromFileTimeUtc(pfi.createTime); + } + catch + { + dtCreate.Enabled = false; + tCreateAsNumber.Text = pfi.createTime.ToString(); + } + + try + { + dtModified.Value = DateTime.FromFileTimeUtc(pfi.modifyTime); + } + catch + { + dtModified.Enabled = false; + tModifyAsNumber.Text = pfi.modifyTime.ToString(); + } tOffset.Text = "0x" + pfi.offset.ToString("X"); @@ -368,7 +385,22 @@ private bool ValidateFields() try { - newInfo.createTime = dtCreate.Value.ToFileTime(); + dtCreate.Enabled = string.IsNullOrWhiteSpace(tCreateAsNumber.Text); + if (dtCreate.Enabled) + newInfo.createTime = dtCreate.Value.ToFileTimeUtc(); + else + { + if (TryFieldParse(tCreateAsNumber.Text, out long nCreateTime)) + { + newInfo.createTime = nCreateTime; + } + else + { + warnings += "Create Time is not a valid number\r\n"; + res = false; + } + + } } catch { @@ -378,7 +410,22 @@ private bool ValidateFields() try { - newInfo.modifyTime = dtModified.Value.ToFileTime(); + dtModified.Enabled = string.IsNullOrWhiteSpace(tModifyAsNumber.Text); + if (dtModified.Enabled) + newInfo.modifyTime = dtModified.Value.ToFileTimeUtc(); + else + { + if (TryFieldParse(tModifyAsNumber.Text, out long nModifiedTime)) + { + newInfo.modifyTime = nModifiedTime; + } + else + { + warnings += "Modified Time is not a valid number\r\n"; + res = false; + } + + } } catch { @@ -443,5 +490,17 @@ private void tFieldsChanged(object sender, EventArgs e) { btnSave.Enabled = ValidateFields() && hasChanged(); } + + private void lCTtoR_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(tCreateAsNumber.Text)) + tCreateAsNumber.Text = newInfo.createTime.ToString(); + } + + private void lDTToR_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(tModifyAsNumber.Text)) + tModifyAsNumber.Text = newInfo.modifyTime.ToString(); + } } } diff --git a/AAPakEditor/MainForm.Designer.cs b/AAPakEditor/MainForm.Designer.cs index d4fb23f..65e733d 100644 --- a/AAPakEditor/MainForm.Designer.cs +++ b/AAPakEditor/MainForm.Designer.cs @@ -32,12 +32,12 @@ private void InitializeComponent() this.MM = new System.Windows.Forms.MenuStrip(); this.MMFile = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileOpen = new System.Windows.Forms.ToolStripMenuItem(); + this.MMFileTryOpenUsingKeyList = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileSave = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileS1 = new System.Windows.Forms.ToolStripSeparator(); this.MMFileNew = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileClose = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileS2 = new System.Windows.Forms.ToolStripSeparator(); - this.MMFileTryOpenUsingKeyList = new System.Windows.Forms.ToolStripMenuItem(); this.MMFileExit = new System.Windows.Forms.ToolStripMenuItem(); this.MMEdit = new System.Windows.Forms.ToolStripMenuItem(); this.MMEditAddFile = new System.Windows.Forms.ToolStripMenuItem(); @@ -87,6 +87,8 @@ private void InitializeComponent() this.lbExtraFiles = new System.Windows.Forms.ListBox(); this.lTypePak = new System.Windows.Forms.Label(); this.openKeyListDialog = new System.Windows.Forms.OpenFileDialog(); + this.lCreateRaw = new System.Windows.Forms.Label(); + this.lModifiedRaw = new System.Windows.Forms.Label(); this.MM.SuspendLayout(); this.pFileInfo.SuspendLayout(); this.tcDirectoryViews.SuspendLayout(); @@ -132,6 +134,14 @@ private void InitializeComponent() this.MMFileOpen.Text = "&Open ..."; this.MMFileOpen.Click += new System.EventHandler(this.MMFileOpen_Click); // + // MMFileTryOpenUsingKeyList + // + this.MMFileTryOpenUsingKeyList.Name = "MMFileTryOpenUsingKeyList"; + this.MMFileTryOpenUsingKeyList.Size = new System.Drawing.Size(202, 22); + this.MMFileTryOpenUsingKeyList.Text = "Try open using key list ..."; + this.MMFileTryOpenUsingKeyList.Visible = false; + this.MMFileTryOpenUsingKeyList.Click += new System.EventHandler(this.MMExtraTryOpenUsingKeyList_Click); + // // MMFileSave // this.MMFileSave.Name = "MMFileSave"; @@ -167,14 +177,6 @@ private void InitializeComponent() this.MMFileS2.Size = new System.Drawing.Size(199, 6); this.MMFileS2.Click += new System.EventHandler(this.MMFileS2_Click); // - // MMFileTryOpenUsingKeyList - // - this.MMFileTryOpenUsingKeyList.Name = "MMFileTryOpenUsingKeyList"; - this.MMFileTryOpenUsingKeyList.Size = new System.Drawing.Size(202, 22); - this.MMFileTryOpenUsingKeyList.Text = "Try open using key list ..."; - this.MMFileTryOpenUsingKeyList.Visible = false; - this.MMFileTryOpenUsingKeyList.Click += new System.EventHandler(this.MMExtraTryOpenUsingKeyList_Click); - // // MMFileExit // this.MMFileExit.Name = "MMFileExit"; @@ -263,7 +265,7 @@ private void InitializeComponent() // this.MMExportSelectedFile.Name = "MMExportSelectedFile"; this.MMExportSelectedFile.ShortcutKeys = System.Windows.Forms.Keys.F5; - this.MMExportSelectedFile.Size = new System.Drawing.Size(180, 22); + this.MMExportSelectedFile.Size = new System.Drawing.Size(172, 22); this.MMExportSelectedFile.Text = "Selected &File ..."; this.MMExportSelectedFile.Click += new System.EventHandler(this.MMExportSelectedFile_Click); // @@ -271,32 +273,32 @@ private void InitializeComponent() // this.MMExportSelectedFolder.Enabled = false; this.MMExportSelectedFolder.Name = "MMExportSelectedFolder"; - this.MMExportSelectedFolder.Size = new System.Drawing.Size(180, 22); + this.MMExportSelectedFolder.Size = new System.Drawing.Size(172, 22); this.MMExportSelectedFolder.Text = "Selected F&older ..."; this.MMExportSelectedFolder.Click += new System.EventHandler(this.MMExportSelectedFolder_Click); // // MMExportS1 // this.MMExportS1.Name = "MMExportS1"; - this.MMExportS1.Size = new System.Drawing.Size(177, 6); + this.MMExportS1.Size = new System.Drawing.Size(169, 6); // // MMExportAll // this.MMExportAll.Name = "MMExportAll"; this.MMExportAll.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F5))); - this.MMExportAll.Size = new System.Drawing.Size(180, 22); + this.MMExportAll.Size = new System.Drawing.Size(172, 22); this.MMExportAll.Text = "&All Files ..."; this.MMExportAll.Click += new System.EventHandler(this.MMExportAll_Click); // // MMExportS2 // this.MMExportS2.Name = "MMExportS2"; - this.MMExportS2.Size = new System.Drawing.Size(177, 6); + this.MMExportS2.Size = new System.Drawing.Size(169, 6); // // MMExportDB // this.MMExportDB.Name = "MMExportDB"; - this.MMExportDB.Size = new System.Drawing.Size(180, 22); + this.MMExportDB.Size = new System.Drawing.Size(172, 22); this.MMExportDB.Text = "Export DB ..."; this.MMExportDB.Click += new System.EventHandler(this.MMExportDB_Click); // @@ -352,14 +354,14 @@ private void InitializeComponent() // MMVersionSourceCode // this.MMVersionSourceCode.Name = "MMVersionSourceCode"; - this.MMVersionSourceCode.Size = new System.Drawing.Size(180, 22); + this.MMVersionSourceCode.Size = new System.Drawing.Size(141, 22); this.MMVersionSourceCode.Text = "Source Code"; this.MMVersionSourceCode.Click += new System.EventHandler(this.MMVersionSourceCode_Click); // // MMVersionDiscord // this.MMVersionDiscord.Name = "MMVersionDiscord"; - this.MMVersionDiscord.Size = new System.Drawing.Size(180, 22); + this.MMVersionDiscord.Size = new System.Drawing.Size(141, 22); this.MMVersionDiscord.Text = "Visit Discord"; this.MMVersionDiscord.Click += new System.EventHandler(this.VisitDiscordToolStripMenuItem_Click); // @@ -418,11 +420,13 @@ private void InitializeComponent() // this.pFileInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.pFileInfo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pFileInfo.Controls.Add(this.lfiCreateTime); + this.pFileInfo.Controls.Add(this.lfiModifyTime); + this.pFileInfo.Controls.Add(this.lModifiedRaw); + this.pFileInfo.Controls.Add(this.lCreateRaw); this.pFileInfo.Controls.Add(this.lfiIndex); this.pFileInfo.Controls.Add(this.lfiExtras); - this.pFileInfo.Controls.Add(this.lfiModifyTime); this.pFileInfo.Controls.Add(this.lfiStartOffset); - this.pFileInfo.Controls.Add(this.lfiCreateTime); this.pFileInfo.Controls.Add(this.lfiHash); this.pFileInfo.Controls.Add(this.lfiSize); this.pFileInfo.Controls.Add(this.lfiName); @@ -603,6 +607,26 @@ private void InitializeComponent() this.openKeyListDialog.RestoreDirectory = true; this.openKeyListDialog.Title = "Open Key List"; // + // lCreateRaw + // + this.lCreateRaw.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lCreateRaw.Location = new System.Drawing.Point(124, 54); + this.lCreateRaw.Name = "lCreateRaw"; + this.lCreateRaw.Size = new System.Drawing.Size(166, 13); + this.lCreateRaw.TabIndex = 8; + this.lCreateRaw.Text = "( )"; + this.lCreateRaw.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // lModifiedRaw + // + this.lModifiedRaw.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lModifiedRaw.Location = new System.Drawing.Point(124, 70); + this.lModifiedRaw.Name = "lModifiedRaw"; + this.lModifiedRaw.Size = new System.Drawing.Size(166, 13); + this.lModifiedRaw.TabIndex = 9; + this.lModifiedRaw.Text = "( )"; + this.lModifiedRaw.TextAlign = System.Drawing.ContentAlignment.TopRight; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -697,6 +721,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem MMEditFileProp; private System.Windows.Forms.ToolStripMenuItem MMFileTryOpenUsingKeyList; private System.Windows.Forms.OpenFileDialog openKeyListDialog; + private System.Windows.Forms.Label lModifiedRaw; + private System.Windows.Forms.Label lCreateRaw; } } diff --git a/AAPakEditor/MainForm.cs b/AAPakEditor/MainForm.cs index 6efeb0f..4942c5b 100644 --- a/AAPakEditor/MainForm.cs +++ b/AAPakEditor/MainForm.cs @@ -387,14 +387,16 @@ private void ShowFileInfo(AAPakFileInfo pfi) } try { + lCreateRaw.Text = "(" + pfi.createTime.ToString() + ")"; lfiCreateTime.Text = "Created: " + DateTime.FromFileTime(pfi.createTime).ToString(); } catch { - lfiCreateTime.Text = "Invalid creation time"; + lfiCreateTime.Text = "CreateTime Invalid"; } try { + lModifiedRaw.Text = "(" + pfi.modifyTime.ToString() + ")"; if (pfi.modifyTime != 0) lfiModifyTime.Text = "Modified: " + DateTime.FromFileTime(pfi.modifyTime).ToString(); else @@ -402,7 +404,7 @@ private void ShowFileInfo(AAPakFileInfo pfi) } catch { - lfiModifyTime.Text = "Invalid modified time"; + lfiModifyTime.Text = "ModifiedTime Invalid (" + pfi.modifyTime.ToString() + ")"; } lfiStartOffset.Text = "Start Offset: 0x" + pfi.offset.ToString("X16"); lfiExtras.Text = "D1 0x" + pfi.dummy1.ToString("X") + " D2 0x" + pfi.dummy2.ToString("X"); @@ -425,6 +427,8 @@ private void ShowFileInfo(AAPakFileInfo pfi) lfiStartOffset.Text = ""; lfiExtras.Text = ""; lfiIndex.Text = ""; + lCreateRaw.Text = ""; + lModifiedRaw.Text = ""; } } @@ -527,9 +531,9 @@ public bool ExportFile(AAPakFileInfo pfi, string destName) fs.Dispose(); // Update file details - File.SetCreationTime(destName, DateTime.FromFileTime(pfi.createTime)); + File.SetCreationTime(destName, DateTime.FromFileTimeUtc(pfi.createTime)); if (pfi.modifyTime != 0) - File.SetLastWriteTime(destName, DateTime.FromFileTime(pfi.modifyTime)); + File.SetLastWriteTime(destName, DateTime.FromFileTimeUtc(pfi.modifyTime)); } catch { @@ -653,7 +657,7 @@ private void CreateCSVFile(string filename = "") sl.Add(s); foreach (AAPakFileInfo pfi in pak.files) { - DateTime modTime = DateTime.FromFileTime(pfi.modifyTime); + DateTime modTime = DateTime.FromFileTimeUtc(pfi.modifyTime); if (modTime > newest) newest = modTime; @@ -661,7 +665,7 @@ private void CreateCSVFile(string filename = "") s += ";" + pfi.size.ToString(); s += ";" + pfi.offset.ToString(); s += ";" + BitConverter.ToString(pfi.md5).Replace("-","").ToUpper(); - s += ";" + AAPak.DateTimeToDateTimeStr(DateTime.FromFileTime(pfi.createTime)); // .ToString("yyyy-MM-dd HH:mm:ss"); + s += ";" + AAPak.DateTimeToDateTimeStr(DateTime.FromFileTimeUtc(pfi.createTime)); // .ToString("yyyy-MM-dd HH:mm:ss"); s += ";" + AAPak.DateTimeToDateTimeStr(modTime); // .ToString("yyyy-MM-dd HH:mm:ss"); s += ";" + pfi.sizeDuplicate.ToString(); s += ";" + pfi.paddingSize.ToString(); diff --git a/AAPakEditor/MakeModForm.cs b/AAPakEditor/MakeModForm.cs index 83de530..c129edc 100644 --- a/AAPakEditor/MakeModForm.cs +++ b/AAPakEditor/MakeModForm.cs @@ -369,7 +369,7 @@ private void BtnCreateMod_Click(object sender, EventArgs e) if (fi.name.StartsWith(ModFileFolderName)) continue; var ms = mainPak.ExportFileAsStream(fi); - if (!modpak.AddFileFromStream(fi.name,ms,DateTime.FromFileTime(fi.createTime),DateTime.FromFileTime(fi.modifyTime),false,out _)) + if (!modpak.AddFileFromStream(fi.name,ms,DateTime.FromFileTimeUtc(fi.createTime),DateTime.FromFileTimeUtc(fi.modifyTime),false,out _)) { MessageBox.Show("Failed to copy \n"+fi.name+"\nAborting !","Copy Error",MessageBoxButtons.OK,MessageBoxIcon.Error); modpak.ClosePak(); diff --git a/AAPakEditor/Properties/AssemblyInfo.cs b/AAPakEditor/Properties/AssemblyInfo.cs index d6783d4..7e3642f 100644 --- a/AAPakEditor/Properties/AssemblyInfo.cs +++ b/AAPakEditor/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.7.2.5")] -[assembly: AssemblyFileVersion("0.7.2.5")] +[assembly: AssemblyVersion("0.7.3.0")] +[assembly: AssemblyFileVersion("0.7.3.0")] diff --git a/Common/AAPak.cs b/Common/AAPak.cs index 3b36e91..7e50159 100644 --- a/Common/AAPak.cs +++ b/Common/AAPak.cs @@ -1118,6 +1118,11 @@ public static string DateTimeToDateTimeStr(DateTime aTime) return res; } + /// + /// Creates a file time from a given specialized string + /// + /// + /// FILETIME as UTC public static long DateTimeStrToFILETIME(string encodedString) { long res = 0; @@ -1138,7 +1143,7 @@ public static long DateTimeStrToFILETIME(string encodedString) if (!int.TryParse(encodedString.Substring(14, 2), out nn)) nn = 0; if (!int.TryParse(encodedString.Substring(17, 2), out ss)) ss = 0; - res = (new DateTime(yyyy, mm, dd, hh, nn, ss)).ToFileTime(); + res = (new DateTime(yyyy, mm, dd, hh, nn, ss)).ToFileTimeUtc(); } catch { @@ -1456,7 +1461,7 @@ public bool ReplaceFile(ref AAPakFileInfo pfi, Stream sourceStream, DateTime mod pfi.paddingSize = (int)(endPos - pfi.size - pfi.offset); // Recalculate the MD5 hash UpdateMD5(pfi); // TODO: optimize this to calculate WHILE we are copying the stream - pfi.modifyTime = modifyTime.ToFileTime(); + pfi.modifyTime = modifyTime.ToFileTimeUtc(); if (PakType == PakFileType.TypeB) pfi.dummy1 = 0x80000000; @@ -1556,8 +1561,8 @@ public bool AddAsNewFile(string filename, Stream sourceStream, DateTime CreateTi newFile.offset = _header.FirstFileInfoOffset; newFile.size = sourceStream.Length; newFile.sizeDuplicate = newFile.size; - newFile.createTime = CreateTime.ToFileTime(); - newFile.modifyTime = ModifyTime.ToFileTime(); + newFile.createTime = CreateTime.ToFileTimeUtc(); + newFile.modifyTime = ModifyTime.ToFileTimeUtc(); newFile.paddingSize = 0; newFile.md5 = new byte[16]; if (PakType == PakFileType.TypeB)