When converting an IMovie to a TasMovie and auto-generating the filename, check that the file exists, and ensure a non-existent filename
This commit is contained in:
parent
ff95066672
commit
7ffe0805c1
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
using BizHawk.Common.ReflectionExtensions;
|
using BizHawk.Common.ReflectionExtensions;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||||
|
@ -9,7 +11,26 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
{
|
{
|
||||||
public static TasMovie ToTasMovie(this IMovie old)
|
public static TasMovie ToTasMovie(this IMovie old)
|
||||||
{
|
{
|
||||||
var newFilename = old.Filename + "." + TasMovie.Extension;
|
string newFilename = old.Filename + "." + TasMovie.Extension;
|
||||||
|
|
||||||
|
if (File.Exists(newFilename))
|
||||||
|
{
|
||||||
|
int fileNum = 1;
|
||||||
|
bool fileConflict = true;
|
||||||
|
while (fileConflict)
|
||||||
|
{
|
||||||
|
if (File.Exists(newFilename))
|
||||||
|
{
|
||||||
|
newFilename = old.Filename + " (" + fileNum + ")" + "." + TasMovie.Extension;
|
||||||
|
fileNum++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileConflict = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var tas = new TasMovie(newFilename, old.StartsFromSavestate);
|
var tas = new TasMovie(newFilename, old.StartsFromSavestate);
|
||||||
|
|
||||||
for (var i = 0; i < old.InputLogLength; i++)
|
for (var i = 0; i < old.InputLogLength; i++)
|
||||||
|
|
Loading…
Reference in New Issue