[DATFromDir] Try to delete the copied file in more places

This commit is contained in:
Matt Nadareski
2016-09-22 11:17:10 -07:00
parent cfeccbb43d
commit b7ac716d64
2 changed files with 102 additions and 58 deletions

View File

@@ -244,6 +244,13 @@ namespace SabreTools
if (type != null && !_archivesAsFiles)
{
List<Rom> extracted = FileTools.GetArchiveFileInfo(newItem, _logger);
// Cue to delete the file if it's a copy
if (_copyFiles && item != newItem)
{
FileTools.DeleteDirectory(Path.GetDirectoryName(newItem));
}
foreach (Rom rom in extracted)
{
ProcessFileHelper(newItem,
@@ -256,6 +263,12 @@ namespace SabreTools
else if (File.Exists(newItem))
{
ProcessFile(newItem, newBasePath, "");
// Cue to delete the file if it's a copy
if (_copyFiles && item != newItem)
{
FileTools.DeleteDirectory(Path.GetDirectoryName(newItem));
}
}
}
// Otherwise, attempt to extract the files to the temporary directory
@@ -272,6 +285,12 @@ namespace SabreTools
// If the file was an archive and was extracted successfully, check it
if (!encounteredErrors)
{
// Cue to delete the file if it's a copy
if (_copyFiles && item != newItem)
{
FileTools.DeleteDirectory(Path.GetDirectoryName(newItem));
}
_logger.Log(Path.GetFileName(item) + " treated like an archive");
List<string> extracted = Directory.EnumerateFiles(tempSubDir, "*", SearchOption.AllDirectories).ToList();
Parallel.ForEach(extracted,
@@ -290,13 +309,13 @@ namespace SabreTools
else if (File.Exists(newItem))
{
ProcessFile(newItem, newBasePath, "");
}
}
// Cue to delete the file if it's a copy
if (_copyFiles && item != newItem)
{
FileTools.DeleteFile(newItem);
// Cue to delete the file if it's a copy
if (_copyFiles && item != newItem)
{
FileTools.DeleteDirectory(Path.GetDirectoryName(newItem));
}
}
}
// Delete the sub temp directory