/// <summary> /// Updates the date in NewDarkLoader.ini with the date from Darkloader.ini if they are not the same. Assumes latter is correct. /// </summary> private void oldDateToNewDate(INIFile oldINI, INIFile newINI, string oldSectionName, string newSectionName, DateType relPlay, bool fmTypeArchive) { string oldINIDate; string newINIDate; if (relPlay == DateType.Release) { if (fmTypeArchive) { oldINIDate = oldINI.IniReadValue(oldSectionName, "misdate"); } else { oldINIDate = oldINI.INIReadValueNoSize(oldSectionName, "misdate"); } newINIDate = newINI.IniReadValue(newSectionName, nKeys.ReleaseDateInt); } else { if (fmTypeArchive) { oldINIDate = oldINI.IniReadValue(oldSectionName, "date"); } else { oldINIDate = oldINI.INIReadValueNoSize(oldSectionName, "date"); } newINIDate = newINI.IniReadValue(newSectionName, nKeys.LastPlayedInt); } if (oldINIDate != "") { DateTime oldDateTime = DateIntConverter.oldDateIntToDateTime(oldINIDate); if (newINIDate != "") { DateTime newDateTime = DateIntConverter.dateFromHexString(newINIDate); if (oldDateTime != newDateTime) { string hexDate = DateIntConverter.dateToHexString(oldDateTime); writeDateToINI(newINI, newSectionName, relPlay, hexDate); } } else { string hexDate = DateIntConverter.dateToHexString(oldDateTime); writeDateToINI(newINI, newSectionName, relPlay, hexDate); } } }
private void btnImportINI_Click(object sender, EventArgs e) { DialogResult dR = openDarkloaderINI.ShowDialog(); if (dR == DialogResult.OK) { //ini files INIFile oldINI = new INIFile(openDarkloaderINI.FileName); //Get sizes in bytes of each FM file List <string> foundFilesInArchivePaths = new List <string>(); foreach (string path in fmArchiveFullPaths) { foundFilesInArchivePaths.AddRange(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)); } foreach (string file in foundFilesInArchivePaths) { FileInfo fI = new FileInfo(file); long sizeBytes = fI.Length; string ext = fI.Extension; string simpleFilename = fI.Name; string oldSectionName = simpleFilename; bool fmIsArchive = false; if (ext.Length != 0) { simpleFilename = fI.Name.Replace(ext, ""); oldSectionName = simpleFilename + "." + sizeBytes; fmIsArchive = true; } string newSectionName = "FM=" + ArchiveExtract.ArchiveExtracedFolderName(simpleFilename); string newNiceName = newINI.IniReadValue(newSectionName, nKeys.FMTitle); if (newNiceName == simpleFilename || newNiceName == "") { string oldNiceName = oldINI.IniReadValue(oldSectionName, "title").Replace("\"", ""); if (oldNiceName != "") { newINI.IniWriteValue(newSectionName, nKeys.FMTitle, oldNiceName); } } string newFinished = newINI.IniReadValue(newSectionName, nKeys.FinishedID); if (newFinished == "") { string oldFinished; if (fmIsArchive) { oldFinished = oldINI.IniReadValue(oldSectionName, "finished"); } else { oldFinished = oldINI.INIReadValueNoSize(oldSectionName, "finished"); } if (oldFinished != "") { newINI.IniWriteValue(newSectionName, nKeys.FinishedID, oldFinished); } } oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.Release, fmIsArchive); oldDateToNewDate(oldINI, newINI, oldSectionName, newSectionName, DateType.LastPlayed, fmIsArchive); string newComment = newINI.IniReadValue(newSectionName, nKeys.Comment); if (newComment == "") { string oldComment; if (fmIsArchive) { oldComment = oldINI.IniReadValue(oldSectionName, "comment").Replace("\"", ""); } else { oldComment = oldINI.INIReadValueNoSize(oldSectionName, "comment").Replace("\"", ""); } if (oldComment != "") { newINI.IniWriteValue(newSectionName, nKeys.Comment, oldComment); } } } iniImported = true; //allows a property to report that the ini was imported so the main form can refresh the table. } }