void copyDirectory(string patchSource, string patchDestination)
{
String[] patchFiles;
if (patchDestination[patchDestination.Length - 1] != Path.DirectorySeparatorChar)
patchDestination += Path.DirectorySeparatorChar;
if (!Directory.Exists(patchDestination))
Directory.CreateDirectory(patchDestination);
patchFiles = Directory.GetFileSystemEntries(patchSource);
foreach (string Element in patchFiles)
{
if (Directory.Exists(Element))
copyDirectory(Element, patchDestination + Path.GetFileName(Element));
else
{
// If we are replacing an xml, check if the exiting files checksum matches (or it does not have one) and only then copy the file.
// we only want to do checksum compares on Avalon specific skin files
if (Path.GetExtension(Element).ToLower() == ".xml" && patchDestination.StartsWith(SkinInfo.mpPaths.AvalonPath))
{
string destFilename = Path.Combine(patchDestination, Path.GetFileName(Element));
// check if file exists and is a skin file
try
{
//if (checkSum.Compare(destFilename))
File.Copy(Element, destFilename, true);
}
catch (FileNotFoundException)
{
// most likely a new file, copy anyway
File.Copy(Element, destFilename, true);
}
// replace checksum so we can patch next time
//checkSum.Replace(destFilename);
}
else
File.Copy(Element, patchDestination + Path.GetFileName(Element), true);
}
}
}