Open tempIndexFile with FileMode.Create

Probably fixes #4, because it was leaving the old file contents there.
Durr.
This commit is contained in:
Villermen 2014-11-23 23:09:29 +01:00
parent 11a2a6ee10
commit f5df1f4324

View file

@ -391,24 +391,12 @@ namespace RSCacheTool
incomplete = true; incomplete = true;
} }
//copy the first chunk to a temp file so SoX can handle the combining //copy the index's audio chunk to a temp file so SoX can handle the combining
indexFileStream.Position -= 4L; using (FileStream tempIndexFile = File.Open("~index.ogg", FileMode.Create, FileAccess.Write, FileShare.None))
//wait till file is available
while (true)
{ {
try indexFileStream.Position -= 4L; //include OggS
{ indexFileStream.CopyTo(tempIndexFile);
using (FileStream tempIndexFile = File.Open("~index.ogg", FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) break;
{
indexFileStream.CopyTo(tempIndexFile);
break;
}
}
catch (IOException)
{
Thread.Sleep(200);
}
} }
} }
@ -459,9 +447,6 @@ namespace RSCacheTool
Console.WriteLine("Skipping track because it's incomplete."); Console.WriteLine("Skipping track because it's incomplete.");
} }
//cleanup on isle 4
File.Delete("~index.ogg");
Console.WriteLine("Done combining sound."); Console.WriteLine("Done combining sound.");
} }