22 Commits

Author SHA1 Message Date
a612ea5cfd Quick and dirty global setting for forcing un-compression of
sets.
2016-04-17 17:12:48 +01:00
gjefferyes
5a93500001 Thanks to test work done by EDC, this is based on that code, added double buffered file reading, and multi-threader hashing in zip and file checking. V2.2.5 2016-02-12 16:02:48 -06:00
gjefferyes
905574d120 Merge pull request #23 from LnmVolbo/master
Update MESS Software List reader to allow unzipped archives
2016-02-12 09:51:34 -06:00
gjefferyes
063254ccb6 Quck update to add machine to DatXMLReader 2015-12-23 12:03:42 -06:00
LnmVolbo
8a908bf60c Merge pull request #3 from LnmVolbo/LnmVolbo-patch-1
Update DatMessXMLReader.cs
2015-09-25 13:14:17 -07:00
LnmVolbo
239b001daa Update DatMessXMLReader.cs
These changes are intended to allow the MESS software list items to be saved as files instead of zip archives.

The reasoning behind this is to allow users with compressed volumes to avoid having to take the performance hit of compressing everything twice - or having to convert all their xml based .dat files to clrmamepro .dat file format to take advantage of the  'forcezipping no' tag.

These changes were made with the code from DatXmlReader.cs as a model.
2015-09-25 13:09:15 -07:00
LnmVolbo
03141ff8f0 Merge pull request #2 from gjefferyes/master
Update to changes on 9/16
2015-09-25 12:51:18 -07:00
gjefferyes
e6e0c73dcd Version 2.2.4 2015-09-16 20:52:03 -05:00
gjefferyes
7d25bd8519 Merge pull request #15 from LnmVolbo/master
Keep contrast up on GameGrid and RomGrid
2015-09-16 20:22:14 -05:00
gjefferyes
c61eead2ba #16
Changed
  SelectedPath = @"apps"
to
 SelectedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Reports")
2015-09-16 20:18:21 -05:00
gjefferyes
2d6c5a7e26 #18
replaced:
Environment.SpecialFolder.DesktopDirectory
with
Environment.SpecialFolder.MyComputer
2015-09-16 20:14:17 -05:00
gjefferyes
b6be1a9ec1 #19 Fixed possible hard Crash when scanning files. 2015-09-16 20:09:54 -05:00
gjefferyes
5107b5b850 Removed DatMessBIOSReader due to MAME and MESS being combined. 2015-09-16 20:01:03 -05:00
gjefferyes
33f204fc37 Cleaned up Natalia Portillo's Mess Bios xml Reader. 2015-09-16 17:41:26 -05:00
gjefferyes
dc99d2328d Merge pull request #13 from claunia/master
Added support for MESS BIOS xml datlist (mess -listxml)
2015-09-16 17:37:12 -05:00
gjefferyes
0817f01538 When making a dir2dat, the "clean" routine overdoes it when translating the apostrophes, Fixed by changing order of code. 2015-09-16 17:20:58 -05:00
LnmVolbo
1b4caa8e34 Update FrmMain.cs - 2nd rev.
This time I have pre-computed all the font colors into a table named _fontColor.

These pre-computed values are created as soon as the _displayColor table is finished being created.

Using these pre-computed values is more efficient than computing them for every entry in the GameGrid and RomGrid.
2015-06-23 09:04:26 -07:00
LnmVolbo
6981a16a67 Update FrmMain.cs
Haven't got the knack of getting the edited source straight out of my visual studio IDE, so I'm just copying and pasting bits here.  So I'm not really sure if it still compiles w/o errors.
2015-06-22 19:37:52 -07:00
LnmVolbo
14054dc06f Merge pull request #1 from gjefferyes/master
pull request tryout
2015-06-22 19:23:36 -07:00
gjefferyes
c04bb9d070 Fixed a baddump merging issue (Thanks to Marco for the details to fix this.) 2015-06-11 10:12:36 -05:00
gjefferyes
32f67308fa fixed loading the mame 0.162 dat's using the 'machine' xml node. 2015-06-10 09:45:03 -05:00
efaba1f3d9 Added support for MESS BIOS xml datlist (mess -listxml) 2015-03-30 23:04:20 +01:00
16 changed files with 253 additions and 110 deletions

View File

@@ -57,11 +57,11 @@ namespace ROMVault2
private static string clean(string s) private static string clean(string s)
{ {
s = s.Replace("&", "&");
s = s.Replace("\"", """); s = s.Replace("\"", """);
s = s.Replace("'", "'"); s = s.Replace("'", "'");
s = s.Replace("<", "&lt;"); s = s.Replace("<", "&lt;");
s = s.Replace(">", "&gt;"); s = s.Replace(">", "&gt;");
s = s.Replace("&", "&amp;");
return s; return s;
} }

View File

@@ -142,6 +142,8 @@ namespace ROMVault2.DatReaders
} }
thisFileType = forceZipping.ToLower() != "no" ? FileType.ZipFile : FileType.File; thisFileType = forceZipping.ToLower() != "no" ? FileType.ZipFile : FileType.File;
if (Settings.FixLevel == eFixLevel.Uncompressed)
thisFileType = FileType.File;
tDir.Dat = tDat; tDir.Dat = tDat;
return true; return true;

View File

@@ -97,7 +97,7 @@ namespace ROMVault2.DatReaders
} }
} }
thisFileType = FileType.ZipFile; thisFileType = Settings.FixLevel == eFixLevel.Uncompressed ? FileType.File : FileType.ZipFile;
tDir.Dat = tDat; tDir.Dat = tDat;
return true; return true;

View File

@@ -16,7 +16,9 @@ namespace ROMVault2.DatReaders
public static bool ReadDat(ref RvDir tDat, XmlDocument doc) public static bool ReadDat(ref RvDir tDat, XmlDocument doc)
{ {
if (!LoadHeaderFromDat(ref tDat, ref doc)) FileType thisFileType = FileType.Unknown;
if (!LoadHeaderFromDat(ref tDat, ref doc, ref thisFileType))
return false; return false;
if (doc.DocumentElement == null) if (doc.DocumentElement == null)
@@ -27,13 +29,13 @@ namespace ROMVault2.DatReaders
return false; return false;
for (int i = 0; i < gameNodeList.Count; i++) for (int i = 0; i < gameNodeList.Count; i++)
{ {
LoadGameFromDat(ref tDat, gameNodeList[i]); LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType);
} }
return true; return true;
} }
private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc) private static bool LoadHeaderFromDat(ref RvDir tDir, ref XmlDocument doc, ref FileType thisFileType)
{ {
XmlNodeList head = doc.SelectNodes("softwarelist"); XmlNodeList head = doc.SelectNodes("softwarelist");
if (head == null) if (head == null)
@@ -62,21 +64,38 @@ namespace ROMVault2.DatReaders
tDat.AddData(RvDat.DatData.MergeType, "split"); tDat.AddData(RvDat.DatData.MergeType, "split");
break; break;
} }
val = VarFix.String(head[0].Attributes.GetNamedItem("forcepacking")).ToLower();
switch (val.ToLower())
{
case "zip":
tDat.AddData(RvDat.DatData.FileType, "zip");
thisFileType = FileType.ZipFile;
break;
case "unzip":
case "file":
tDat.AddData(RvDat.DatData.FileType, "file");
thisFileType = FileType.File;
break;
default:
thisFileType = FileType.ZipFile;
break;
}
if (Settings.FixLevel == eFixLevel.Uncompressed)
thisFileType = FileType.File;
tDir.Dat = tDat; tDir.Dat = tDat;
return true; return true;
} }
private static void LoadGameFromDat(ref RvDir tDat, XmlNode gameNode) private static void LoadGameFromDat(ref RvDir tDat, XmlNode gameNode, FileType thisFileType)
{ {
if (gameNode.Attributes == null) if (gameNode.Attributes == null)
return; return;
RvDir parent = tDat; RvDir parent = tDat;
RvDir tDir = new RvDir(FileType.Zip) RvDir tDir = new RvDir(DBTypeGet.DirFromFile(thisFileType))
{ {
Name = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("name")), Name = VarFix.CleanFileName(gameNode.Attributes.GetNamedItem("name")),
Game = new RvGame(), Game = new RvGame(),
@@ -137,7 +156,7 @@ namespace ROMVault2.DatReaders
if (romNodeList != null) if (romNodeList != null)
for (int iR = 0; iR < romNodeList.Count; iR++) for (int iR = 0; iR < romNodeList.Count; iR++)
{ {
LoadRomFromDat(ref tDir, romNodeList[iR]); LoadRomFromDat(ref tDir, romNodeList[iR], thisFileType);
} }
} }
} }
@@ -164,7 +183,7 @@ namespace ROMVault2.DatReaders
} }
private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode) private static void LoadRomFromDat(ref RvDir tGame, XmlNode romNode, FileType thisFileType)
{ {
if (romNode.Attributes == null) if (romNode.Attributes == null)
return; return;
@@ -173,7 +192,7 @@ namespace ROMVault2.DatReaders
string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag")); string loadflag = VarFix.String(romNode.Attributes.GetNamedItem("loadflag"));
if (name != null) if (name != null)
{ {
RvFile tRom = new RvFile(FileType.ZipFile) RvFile tRom = new RvFile(thisFileType) // changed
{ {
Name = VarFix.CleanFullFileName(name), Name = VarFix.CleanFullFileName(name),
Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")), Size = VarFix.ULong(romNode.Attributes.GetNamedItem("size")),

View File

@@ -270,6 +270,10 @@ namespace ROMVault2.DatReaders
// loop the ROMs in the parent sets // loop the ROMs in the parent sets
for (int r1 = 0; r1 < romofGame.ChildCount; r1++) for (int r1 = 0; r1 < romofGame.ChildCount; r1++)
{ {
// don't search fixes for files marked as nodump
if (((RvFile)mGame.Child(r)).Status == "nodump" || ((RvFile)romofGame.Child(r1)).Status == "nodump")
continue;
// only find fixes if the Name and the Size of the ROMs are the same // only find fixes if the Name and the Size of the ROMs are the same
if (mGame.Child(r).Name != romofGame.Child(r1).Name || ((RvFile)mGame.Child(r)).Size != ((RvFile)romofGame.Child(r1)).Size) if (mGame.Child(r).Name != romofGame.Child(r1).Name || ((RvFile)mGame.Child(r)).Size != ((RvFile)romofGame.Child(r1)).Size)
continue; continue;
@@ -285,11 +289,13 @@ namespace ROMVault2.DatReaders
if (b1) if (b1)
{ {
((RvFile)mGame.Child(r)).CRC = ((RvFile)romofGame.Child(r1)).CRC; ((RvFile)mGame.Child(r)).CRC = ((RvFile)romofGame.Child(r1)).CRC;
((RvFile)mGame.Child(r)).FileStatusSet(FileStatus.CRCFromDAT);
((RvFile)mGame.Child(r)).Status = "(CRCFound)"; ((RvFile)mGame.Child(r)).Status = "(CRCFound)";
} }
else else
{ {
((RvFile)romofGame.Child(r1)).CRC = ((RvFile)mGame.Child(r)).CRC; ((RvFile)romofGame.Child(r1)).CRC = ((RvFile)mGame.Child(r)).CRC;
((RvFile)romofGame.Child(r1)).FileStatusSet(FileStatus.CRCFromDAT);
((RvFile)romofGame.Child(r1)).Status = "(CRCFound)"; ((RvFile)romofGame.Child(r1)).Status = "(CRCFound)";
} }
@@ -428,6 +434,8 @@ namespace ROMVault2.DatReaders
byte[] chdMD51 = ((RvFile)romofGame.Child(r1)).MD5CHD; byte[] chdMD51 = ((RvFile)romofGame.Child(r1)).MD5CHD;
if (chdMD50 != null && chdMD51 != null && !ArrByte.bCompare(chdMD50, chdMD51)) continue; if (chdMD50 != null && chdMD51 != null && !ArrByte.bCompare(chdMD50, chdMD51)) continue;
// don't merge if only one of the ROM is nodump
if ((((RvFile)romofGame.Child(r1)).Status == "nodump") != (((RvFile)mGame.Child(r)).Status == "nodump")) continue;
found = true; found = true;
break; break;
@@ -446,9 +454,9 @@ namespace ROMVault2.DatReaders
return; return;
string parentName = searchGame.Game.GetData(RvGame.GameData.RomOf); string parentName = searchGame.Game.GetData(RvGame.GameData.RomOf);
if (String.IsNullOrEmpty(parentName) || parentName==searchGame.Name) if (String.IsNullOrEmpty(parentName) || parentName == searchGame.Name)
parentName = searchGame.Game.GetData(RvGame.GameData.CloneOf); parentName = searchGame.Game.GetData(RvGame.GameData.CloneOf);
if (String.IsNullOrEmpty(parentName) || parentName==searchGame.Name) if (String.IsNullOrEmpty(parentName) || parentName == searchGame.Name)
return; return;
int intIndex; int intIndex;

View File

@@ -28,20 +28,24 @@ namespace ROMVault2.DatReaders
XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir"); XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir");
if (dirNodeList != null) if (dirNodeList != null)
{ {
for (int i = 0; i < dirNodeList.Count; i++) foreach (XmlNode dirNode in dirNodeList)
{ LoadDirFromDat(ref tDat, dirNode, thisFileType);
LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType);
}
} }
XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game"); XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game");
if (gameNodeList != null) if (gameNodeList != null)
{ {
for (int i = 0; i < gameNodeList.Count; i++) foreach (XmlNode gameNode in gameNodeList)
{ LoadGameFromDat(ref tDat, gameNode, thisFileType);
LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType); }
}
XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine");
if (machineNodeList != null)
{
foreach (XmlNode machineNode in machineNodeList)
LoadGameFromDat(ref tDat, machineNode, thisFileType);
} }
return true; return true;
@@ -60,22 +64,27 @@ namespace ROMVault2.DatReaders
XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir"); XmlNodeList dirNodeList = doc.DocumentElement.SelectNodes("dir");
if (dirNodeList != null) if (dirNodeList != null)
{ {
for (int i = 0; i < dirNodeList.Count; i++) foreach (XmlNode dirNode in dirNodeList)
{ LoadDirFromDat(ref tDat, dirNode, thisFileType);
LoadDirFromDat(ref tDat, dirNodeList[i], thisFileType);
}
} }
XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game"); XmlNodeList gameNodeList = doc.DocumentElement.SelectNodes("game");
if (gameNodeList != null) if (gameNodeList != null)
{ {
for (int i = 0; i < gameNodeList.Count; i++) foreach (XmlNode gameNode in gameNodeList)
{ LoadGameFromDat(ref tDat, gameNode, thisFileType);
LoadGameFromDat(ref tDat, gameNodeList[i], thisFileType);
}
} }
XmlNodeList machineNodeList = doc.DocumentElement.SelectNodes("machine");
if (machineNodeList != null)
{
foreach (XmlNode machineNode in machineNodeList)
LoadGameFromDat(ref tDat, machineNode, thisFileType);
}
return true; return true;
} }
@@ -149,13 +158,15 @@ namespace ROMVault2.DatReaders
} }
val = VarFix.String(packingNode.Attributes.GetNamedItem("dir")).ToLower(); // noautodir , nogame val = VarFix.String(packingNode.Attributes.GetNamedItem("dir")).ToLower(); // noautodir , nogame
if (!String.IsNullOrEmpty(val)) if (!String.IsNullOrEmpty(val))
tDat.AddData(RvDat.DatData.DirSetup,val); tDat.AddData(RvDat.DatData.DirSetup, val);
} }
} }
// Look for: <notzipped>true</notzipped> // Look for: <notzipped>true</notzipped>
string notzipped = VarFix.String(head.SelectSingleNode("notzipped")); string notzipped = VarFix.String(head.SelectSingleNode("notzipped"));
if (notzipped.ToLower() == "true" || notzipped.ToLower() == "yes") thisFileType = FileType.File; if (notzipped.ToLower() == "true" || notzipped.ToLower() == "yes") thisFileType = FileType.File;
if (Settings.FixLevel == eFixLevel.Uncompressed)
thisFileType = FileType.File;
tDir.Dat = tDat; tDir.Dat = tDat;
return true; return true;

View File

@@ -33,6 +33,7 @@ namespace ROMVault2
private static readonly Color CWhite = Color.FromArgb(255, 255, 255); private static readonly Color CWhite = Color.FromArgb(255, 255, 255);
private readonly Color[] _displayColor; private readonly Color[] _displayColor;
private readonly Color[] _fontColor;
private bool _updatingGameGrid; private bool _updatingGameGrid;
@@ -70,6 +71,7 @@ namespace ROMVault2
_displayColor = new Color[(int)RepStatus.EndValue]; _displayColor = new Color[(int)RepStatus.EndValue];
_fontColor = new Color[(int)RepStatus.EndValue];
// RepStatus.UnSet // RepStatus.UnSet
@@ -101,6 +103,9 @@ namespace ROMVault2
_displayColor[(int)RepStatus.Deleted] = CWhite; _displayColor[(int)RepStatus.Deleted] = CWhite;
for (int i = 0; i < (int)RepStatus.EndValue; i++)
_fontColor[i] = contrasty(_displayColor[i]);
_gameGridColumnXPositions = new int[(int)RepStatus.EndValue]; _gameGridColumnXPositions = new int[(int)RepStatus.EndValue];
DirTree.Setup(ref DB.DirTree); DirTree.Setup(ref DB.DirTree);
@@ -745,6 +750,7 @@ namespace ROMVault2
RvDir tRvDir = (RvDir)GameGrid.Rows[e.RowIndex].Tag; RvDir tRvDir = (RvDir)GameGrid.Rows[e.RowIndex].Tag;
ReportStatus tDirStat = tRvDir.DirStatus; ReportStatus tDirStat = tRvDir.DirStatus;
Color bgCol = Color.FromArgb(255, 255, 255); Color bgCol = Color.FromArgb(255, 255, 255);
Color fgCol = Color.FromArgb(0, 0, 0);
if (cellBounds.Width == 0 || cellBounds.Height == 0) if (cellBounds.Width == 0 || cellBounds.Height == 0)
return; return;
@@ -754,6 +760,7 @@ namespace ROMVault2
if (tDirStat.Get(t1) <= 0) continue; if (tDirStat.Get(t1) <= 0) continue;
bgCol = _displayColor[(int)t1]; bgCol = _displayColor[(int)t1];
fgCol = _fontColor[(int)t1];
break; break;
} }
@@ -761,6 +768,7 @@ namespace ROMVault2
{ {
e.CellStyle.BackColor = bgCol; e.CellStyle.BackColor = bgCol;
e.CellStyle.SelectionBackColor = bgCol; e.CellStyle.SelectionBackColor = bgCol;
e.CellStyle.ForeColor = fgCol;
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height); Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
@@ -799,6 +807,7 @@ namespace ROMVault2
else if (GameGrid.Columns[e.ColumnIndex].Name == "CGame") else if (GameGrid.Columns[e.ColumnIndex].Name == "CGame")
{ {
e.CellStyle.BackColor = bgCol; e.CellStyle.BackColor = bgCol;
e.CellStyle.ForeColor = fgCol;
if (String.IsNullOrEmpty(tRvDir.FileName)) if (String.IsNullOrEmpty(tRvDir.FileName))
e.Value = tRvDir.Name; e.Value = tRvDir.Name;
@@ -808,6 +817,7 @@ namespace ROMVault2
else if (GameGrid.Columns[e.ColumnIndex].Name == "CDescription") else if (GameGrid.Columns[e.ColumnIndex].Name == "CDescription")
{ {
e.CellStyle.BackColor = bgCol; e.CellStyle.BackColor = bgCol;
e.CellStyle.ForeColor = fgCol;
if (tRvDir.Game != null) if (tRvDir.Game != null)
e.Value = tRvDir.Game.GetData(RvGame.GameData.Description); e.Value = tRvDir.Game.GetData(RvGame.GameData.Description);
@@ -1292,6 +1302,13 @@ namespace ROMVault2
} }
} }
// returns either white or black, depending of quick luminance of the Color " a "
// called when the _displayColor is finished, in order to populate the _fontColor table.
private Color contrasty(Color a)
{
return (a.R << 1) + a.B + a.G + (a.G << 2) < 1024 ? Color.White : Color.Black;
}
private void AddRom(RvFile tRomTable, string pathAdd) private void AddRom(RvFile tRomTable, string pathAdd)
{ {
@@ -1302,8 +1319,11 @@ namespace ROMVault2
RomGrid.Rows[row].Tag = tRomTable; RomGrid.Rows[row].Tag = tRomTable;
for (int i = 0; i < RomGrid.Rows[row].Cells.Count; i++) for (int i = 0; i < RomGrid.Rows[row].Cells.Count; i++)
RomGrid.Rows[row].Cells[i].Style.BackColor = _displayColor[(int)tRomTable.RepStatus]; {
DataGridViewCellStyle cs = RomGrid.Rows[row].Cells[i].Style;
cs.BackColor = _displayColor[(int)tRomTable.RepStatus];
cs.ForeColor = _fontColor[(int)tRomTable.RepStatus];
}
string fname = pathAdd + tRomTable.Name; string fname = pathAdd + tRomTable.Name;
if (!string.IsNullOrEmpty(tRomTable.FileName)) if (!string.IsNullOrEmpty(tRomTable.FileName))
fname += " (Found: " + tRomTable.FileName + ")"; fname += " (Found: " + tRomTable.FileName + ")";
@@ -1441,6 +1461,7 @@ namespace ROMVault2
private void SettingsToolStripMenuItemClick(object sender, EventArgs e) private void SettingsToolStripMenuItemClick(object sender, EventArgs e)
{ {
FrmSettings fcfg = new FrmSettings(); FrmSettings fcfg = new FrmSettings();
fcfg.UpdateDats += UpdateDats;
fcfg.ShowDialog(this); fcfg.ShowDialog(this);
fcfg.Dispose(); fcfg.Dispose();
} }

View File

@@ -80,7 +80,7 @@ namespace ROMVault2
{ {
ShowNewFolderButton = true, ShowNewFolderButton = true,
Description = Resources.FrmSetDir_BtnSetRomLocationClick_Please_select_a_folder_for_This_Rom_Set, Description = Resources.FrmSetDir_BtnSetRomLocationClick_Please_select_a_folder_for_This_Rom_Set,
RootFolder = (Settings.IsMono ? Environment.SpecialFolder.MyComputer : Environment.SpecialFolder.DesktopDirectory), RootFolder = Environment.SpecialFolder.MyComputer,
SelectedPath = DBHelper.GetRealPath(_datLocation) SelectedPath = DBHelper.GetRealPath(_datLocation)
}; };
if (browse.ShowDialog() == DialogResult.OK) if (browse.ShowDialog() == DialogResult.OK)

View File

@@ -8,11 +8,17 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using ROMVault2.Properties; using ROMVault2.Properties;
using System.IO;
using ROMVault2.RvDB;
namespace ROMVault2 namespace ROMVault2
{ {
public partial class FrmSettings : Form public partial class FrmSettings : Form
{ {
public delegate void UpdateDatsDelegate();
public event UpdateDatsDelegate UpdateDats;
public FrmSettings() public FrmSettings()
{ {
InitializeComponent(); InitializeComponent();
@@ -29,6 +35,7 @@ namespace ROMVault2
cboFixLevel.Items.Add("Level1"); cboFixLevel.Items.Add("Level1");
cboFixLevel.Items.Add("Level2"); cboFixLevel.Items.Add("Level2");
cboFixLevel.Items.Add("Level3"); cboFixLevel.Items.Add("Level3");
cboFixLevel.Items.Add("Uncompressed");
} }
private void FrmConfigLoad(object sender, EventArgs e) private void FrmConfigLoad(object sender, EventArgs e)
@@ -54,6 +61,26 @@ namespace ROMVault2
private void BtnOkClick(object sender, EventArgs e) private void BtnOkClick(object sender, EventArgs e)
{ {
if (Settings.FixLevel != (eFixLevel)cboFixLevel.SelectedIndex)
{
if (Settings.FixLevel == eFixLevel.Uncompressed ||
(eFixLevel)cboFixLevel.SelectedIndex == eFixLevel.Uncompressed)
{
DialogResult dlg = MessageBox.Show("Changing from/to uncompressed requires the cache file to be deleted.\nDo you want to proceed?", "Settings", MessageBoxButtons.YesNoCancel);
if (dlg == DialogResult.Cancel)
Close();
if (dlg != DialogResult.Yes)
return;
File.Delete(Settings.CacheFile);
DB.Read(sender, new System.ComponentModel.DoWorkEventArgs(null));
Settings.FixLevel = (eFixLevel)cboFixLevel.SelectedIndex;
UpdateDats();
}
}
Settings.DatRoot = lblDATRoot.Text; Settings.DatRoot = lblDATRoot.Text;
Settings.ScanLevel = (eScanLevel)cboScanLevel.SelectedIndex; Settings.ScanLevel = (eScanLevel)cboScanLevel.SelectedIndex;
Settings.FixLevel = (eFixLevel)cboFixLevel.SelectedIndex; Settings.FixLevel = (eFixLevel)cboFixLevel.SelectedIndex;
@@ -88,7 +115,7 @@ namespace ROMVault2
{ {
ShowNewFolderButton = true, ShowNewFolderButton = true,
Description = Resources.FrmSettings_BtnDatClick_Please_select_a_folder_for_DAT_Root, Description = Resources.FrmSettings_BtnDatClick_Please_select_a_folder_for_DAT_Root,
RootFolder = (Settings.IsMono ? Environment.SpecialFolder.MyComputer : Environment.SpecialFolder.DesktopDirectory), RootFolder = Environment.SpecialFolder.MyComputer,
SelectedPath = Settings.DatRoot SelectedPath = Settings.DatRoot
}; };

View File

@@ -15,11 +15,8 @@ namespace ROMVault2
//public static UsernamePassword Up; //public static UsernamePassword Up;
public static readonly Encoding Enc = Encoding.GetEncoding(28591); public static readonly Encoding Enc = Encoding.GetEncoding(28591);
public const string Version = "2.2"; public const string Version = "2.2";
public const int SubVersion = 1; public const int SubVersion = 5;
public static string ErrorMessage;
public static string URL;
public static SynchronizationContext SyncCont; public static SynchronizationContext SyncCont;
/// <summary> /// <summary>
@@ -39,15 +36,7 @@ namespace ROMVault2
progress.ShowDialog(); progress.ShowDialog();
progress.Dispose(); progress.Dispose();
if (!String.IsNullOrEmpty(ErrorMessage))
{
MessageBox.Show(ErrorMessage);
if (!String.IsNullOrEmpty(URL))
System.Diagnostics.Process.Start(URL);
return;
}
Application.Run(new FrmMain()); Application.Run(new FrmMain());
} }
} }

View File

@@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ROMVault2</RootNamespace> <RootNamespace>ROMVault2</RootNamespace>
<AssemblyName>ROMVault22</AssemblyName> <AssemblyName>ROMVault225</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
@@ -35,7 +35,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>Stage\</OutputPath> <OutputPath>..\..\Stage\</OutputPath>
<DefineConstants>TRACE;DEBUG;UNMANAGED;COMPRESS;LZMA_STREAM;DOTNET20</DefineConstants> <DefineConstants>TRACE;DEBUG;UNMANAGED;COMPRESS;LZMA_STREAM;DOTNET20</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>

View File

@@ -40,8 +40,8 @@ namespace ROMVault2
{ {
ShowNewFolderButton = true, ShowNewFolderButton = true,
Description = @"Please select a folder for Dats", Description = @"Please select a folder for Dats",
RootFolder = (Settings.IsMono ? Environment.SpecialFolder.MyComputer : Environment.SpecialFolder.DesktopDirectory), RootFolder = Environment.SpecialFolder.MyComputer,
SelectedPath = @"apps" SelectedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Reports")
}; };
if (browse.ShowDialog() != DialogResult.OK) return; if (browse.ShowDialog() != DialogResult.OK) return;
@@ -195,7 +195,7 @@ namespace ROMVault2
SaveFileDialog saveFileDialog1 = new SaveFileDialog SaveFileDialog saveFileDialog1 = new SaveFileDialog
{ {
Title = @"Generate Full Report", Title = @"Generate Full Report",
FileName = @"RVFullReport"+CleanTime()+".txt", FileName = @"RVFullReport" + CleanTime() + ".txt",
Filter = @"Rom Vault Report (*.txt)|*.txt|All Files (*.*)|*.*", Filter = @"Rom Vault Report (*.txt)|*.txt|All Files (*.*)|*.*",
FilterIndex = 1 FilterIndex = 1
}; };
@@ -226,7 +226,7 @@ namespace ROMVault2
SaveFileDialog saveFileDialog1 = new SaveFileDialog SaveFileDialog saveFileDialog1 = new SaveFileDialog
{ {
Title = @"Generate Fix Report", Title = @"Generate Fix Report",
FileName = @"RVFixReport"+CleanTime()+".txt", FileName = @"RVFixReport" + CleanTime() + ".txt",
Filter = @"Rom Vault Fixing Report (*.txt)|*.txt|All Files (*.*)|*.*", Filter = @"Rom Vault Fixing Report (*.txt)|*.txt|All Files (*.*)|*.*",
FilterIndex = 1 FilterIndex = 1
}; };

View File

@@ -28,7 +28,8 @@ namespace ROMVault2
TrrntZipLevel3, TrrntZipLevel3,
Level1, Level1,
Level2, Level2,
Level3 Level3,
Uncompressed
} }
public static class Settings public static class Settings

View File

@@ -6,18 +6,21 @@
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Threading;
using ROMVault2.SupportedFiles.Zip.ZLib; using ROMVault2.SupportedFiles.Zip.ZLib;
namespace ROMVault2.SupportedFiles.Files namespace ROMVault2.SupportedFiles.Files
{ {
public static class UnCompFiles public static class UnCompFiles
{ {
private const int Buffersize = 4096; private const int Buffersize = 4096 * 1024;
private static readonly byte[] Buffer; private static readonly byte[] Buffer0;
private static readonly byte[] Buffer1;
static UnCompFiles() static UnCompFiles()
{ {
Buffer = new byte[Buffersize]; Buffer0 = new byte[Buffersize];
Buffer1 = new byte[Buffersize];
} }
public static int CheckSumRead(string filename, bool testDeep, out byte[] crc, out byte[] bMD5, out byte[] bSHA1) public static int CheckSumRead(string filename, bool testDeep, out byte[] crc, out byte[] bMD5, out byte[] bSHA1)
@@ -26,11 +29,7 @@ namespace ROMVault2.SupportedFiles.Files
bSHA1 = null; bSHA1 = null;
crc = null; crc = null;
Stream ds; Stream ds = null;
int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
if (errorCode != 0)
return errorCode;
CRC32Hash crc32 = new CRC32Hash(); CRC32Hash crc32 = new CRC32Hash();
MD5 md5 = null; MD5 md5 = null;
@@ -38,24 +37,66 @@ namespace ROMVault2.SupportedFiles.Files
SHA1 sha1 = null; SHA1 sha1 = null;
if (testDeep) sha1 = SHA1.Create(); if (testDeep) sha1 = SHA1.Create();
long sizetogo = ds.Length; try
while (sizetogo > 0)
{ {
int sizenow = sizetogo > Buffersize ? Buffersize : (int)sizetogo; int errorCode = IO.FileStream.OpenFileRead(filename, out ds);
if (errorCode != 0)
return errorCode;
ds.Read(Buffer, 0, sizenow); long sizetogo = ds.Length;
crc32.TransformBlock(Buffer, 0, sizenow, null, 0);
if (testDeep) md5.TransformBlock(Buffer, 0, sizenow, null, 0); // Pre load the first buffer0
if (testDeep) sha1.TransformBlock(Buffer, 0, sizenow, null, 0); int sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
sizetogo -= sizenow; ds.Read(Buffer0, 0, sizeNext);
int sizebuffer = sizeNext;
sizetogo -= sizeNext;
bool whichBuffer = true;
while (sizebuffer > 0)
{
sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
Thread t0 = null;
if (sizeNext > 0)
{
t0 = new Thread(() => { ds.Read(whichBuffer ? Buffer1 : Buffer0, 0, sizeNext); });
t0.Start();
}
byte[] buffer = whichBuffer ? Buffer0 : Buffer1;
Thread t1 = new Thread(() => { crc32.TransformBlock(buffer, 0, sizebuffer, null, 0); });
t1.Start();
if (testDeep)
{
Thread t2 = new Thread(() => { md5.TransformBlock(buffer, 0, sizebuffer, null, 0); });
Thread t3 = new Thread(() => { sha1.TransformBlock(buffer, 0, sizebuffer, null, 0); });
t2.Start();
t3.Start();
t2.Join();
t3.Join();
}
if (t0 != null)
t0.Join();
t1.Join();
sizebuffer = sizeNext;
sizetogo -= sizeNext;
whichBuffer = !whichBuffer;
}
crc32.TransformFinalBlock(Buffer0, 0, 0);
if (testDeep) md5.TransformFinalBlock(Buffer0, 0, 0);
if (testDeep) sha1.TransformFinalBlock(Buffer0, 0, 0);
ds.Close();
} }
catch
{
if (ds != null)
ds.Close();
crc32.TransformFinalBlock(Buffer, 0, 0); return 0x17;
if (testDeep) md5.TransformFinalBlock(Buffer, 0, 0); }
if (testDeep) sha1.TransformFinalBlock(Buffer, 0, 0);
ds.Close();
crc = crc32.Hash; crc = crc32.Hash;
if (testDeep) bMD5 = md5.Hash; if (testDeep) bMD5 = md5.Hash;
@@ -63,8 +104,5 @@ namespace ROMVault2.SupportedFiles.Files
return 0; return 0;
} }
} }
} }

View File

@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading;
using ROMVault2.SupportedFiles.Zip.ZLib; using ROMVault2.SupportedFiles.Zip.ZLib;
// UInt16 = ushort // UInt16 = ushort
@@ -17,11 +18,12 @@ using ROMVault2.SupportedFiles.Zip.ZLib;
namespace ROMVault2.SupportedFiles.Zip namespace ROMVault2.SupportedFiles.Zip
{ {
public class ZipFile public class ZipFile
{ {
const int Buffersize = 4096 * 128; const int Buffersize = 4096 * 1024;
private static byte[] _buffer; private static byte[] _buffer0;
private static byte[] _buffer1;
private const uint LocalFileHeaderSignature = 0x04034b50; private const uint LocalFileHeaderSignature = 0x04034b50;
private const uint CentralDirectoryHeaderSigniature = 0x02014b50; private const uint CentralDirectoryHeaderSigniature = 0x02014b50;
@@ -48,10 +50,10 @@ namespace ROMVault2.SupportedFiles.Zip
public bool Zip64 { get; private set; } public bool Zip64 { get; private set; }
public bool TrrntZip { get; private set; } public bool TrrntZip { get; private set; }
public byte[] sha1 { get; private set; } public byte[] sha1 { get; private set; }
public byte[] md5 { get; private set; } public byte[] md5 { get; private set; }
public ZipReturn FileStatus = ZipReturn.ZipUntested; public ZipReturn FileStatus = ZipReturn.ZipUntested;
public LocalFile(Stream zipFs) public LocalFile(Stream zipFs)
{ {
@@ -414,7 +416,7 @@ namespace ROMVault2.SupportedFiles.Zip
_generalPurposeBitFlag = br.ReadUInt16(); _generalPurposeBitFlag = br.ReadUInt16();
if ((_generalPurposeBitFlag & 8) == 8) if ((_generalPurposeBitFlag & 8) == 8)
return ZipReturn.ZipCannotFastOpen; return ZipReturn.ZipCannotFastOpen;
_compressionMethod = br.ReadUInt16(); _compressionMethod = br.ReadUInt16();
_lastModFileTime = br.ReadUInt16(); _lastModFileTime = br.ReadUInt16();
_lastModFileDate = br.ReadUInt16(); _lastModFileDate = br.ReadUInt16();
@@ -482,7 +484,7 @@ namespace ROMVault2.SupportedFiles.Zip
_dataLocation = (ulong)_zipFs.Position; _dataLocation = (ulong)_zipFs.Position;
return ZipReturn.ZipGood; return ZipReturn.ZipGood;
} }
catch catch
{ {
@@ -717,25 +719,53 @@ namespace ROMVault2.SupportedFiles.Zip
MD5 lmd5 = System.Security.Cryptography.MD5.Create(); MD5 lmd5 = System.Security.Cryptography.MD5.Create();
SHA1 lsha1 = System.Security.Cryptography.SHA1.Create(); SHA1 lsha1 = System.Security.Cryptography.SHA1.Create();
ulong sizetogo = UncompressedSize; if (_buffer0 == null)
if (_buffer == null)
_buffer = new byte[Buffersize];
while (sizetogo > 0)
{ {
int sizenow = sizetogo > Buffersize ? Buffersize : (int)sizetogo; _buffer0 = new byte[Buffersize];
sInput.Read(_buffer, 0, sizenow); _buffer1 = new byte[Buffersize];
crc32.TransformBlock(_buffer, 0, sizenow, null, 0);
lmd5.TransformBlock(_buffer, 0, sizenow, null, 0);
lsha1.TransformBlock(_buffer, 0, sizenow, null, 0);
sizetogo = sizetogo - (ulong)sizenow;
} }
crc32.TransformFinalBlock(_buffer, 0, 0); ulong sizetogo = UncompressedSize;
lmd5.TransformFinalBlock(_buffer, 0, 0);
lsha1.TransformFinalBlock(_buffer, 0, 0); // Pre load the first buffer0
int sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
sInput.Read(_buffer0, 0, sizeNext);
int sizebuffer = sizeNext;
sizetogo -= (ulong)sizeNext;
bool whichBuffer = true;
while (sizebuffer > 0)
{
sizeNext = sizetogo > Buffersize ? Buffersize : (int)sizetogo;
Thread t0 = null;
if (sizeNext > 0)
{
t0 = new Thread(() => { sInput.Read(whichBuffer ? _buffer1 : _buffer0, 0, sizeNext); });
t0.Start();
}
byte[] buffer = whichBuffer ? _buffer0 : _buffer1;
Thread t1 = new Thread(() => { crc32.TransformBlock(buffer, 0, sizebuffer, null, 0); });
Thread t2 = new Thread(() => { lmd5.TransformBlock(buffer, 0, sizebuffer, null, 0); });
Thread t3 = new Thread(() => { lsha1.TransformBlock(buffer, 0, sizebuffer, null, 0); });
t1.Start();
t2.Start();
t3.Start();
if (t0 != null)
t0.Join();
t1.Join();
t2.Join();
t3.Join();
sizebuffer = sizeNext;
sizetogo -= (ulong)sizeNext;
whichBuffer = !whichBuffer;
}
crc32.TransformFinalBlock(_buffer0, 0, 0);
lmd5.TransformFinalBlock(_buffer0, 0, 0);
lsha1.TransformFinalBlock(_buffer0, 0, 0);
byte[] testcrc = crc32.Hash; byte[] testcrc = crc32.Hash;
md5 = lmd5.Hash; md5 = lmd5.Hash;
@@ -1365,7 +1395,7 @@ namespace ROMVault2.SupportedFiles.Zip
_localFiles[_localFiles.Count - 1].LocalFileAddDirectory(); _localFiles[_localFiles.Count - 1].LocalFileAddDirectory();
} }
/* /*
public void BreakTrrntZip(string filename) public void BreakTrrntZip(string filename)
{ {
@@ -1525,7 +1555,7 @@ namespace ROMVault2.SupportedFiles.Zip
int pos1 = 0; int pos1 = 0;
int pos2 = 0; int pos2 = 0;
for (; ; ) for (;;)
{ {
if (pos1 == bytes1.Length) if (pos1 == bytes1.Length)
return ((pos2 == bytes2.Length) ? 0 : -1); return ((pos2 == bytes2.Length) ? 0 : -1);

View File

@@ -11,10 +11,7 @@ namespace ROMVault2
{ {
public static class rvImages public static class rvImages
{ {
private static List<string> names;
private static List<Bitmap> images;
public static Bitmap GetBitmap(string bitmapName) public static Bitmap GetBitmap(string bitmapName)
{ {
object bmObj = rvImages1.ResourceManager.GetObject(bitmapName); object bmObj = rvImages1.ResourceManager.GetObject(bitmapName);