diff --git a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs index 65c4035f96..d11feae8c5 100644 --- a/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs +++ b/src/BizHawk.Client.EmuHawk/AVOut/FFmpegDownloaderForm.cs @@ -40,6 +40,9 @@ namespace BizHawk.Client.EmuHawk try { + DirectoryInfo parentDir = new(Path.GetDirectoryName(FFmpegService.FFmpegPath)!); + if (!parentDir.Exists) parentDir.Create(); + using var fs = File.Create(FFmpegService.FFmpegPath); // check writable before bothering with the download using (var evt = new ManualResetEvent(false)) { using (var client = new System.Net.WebClient()) @@ -83,15 +86,11 @@ namespace BizHawk.Client.EmuHawk { using (var exe = OSTailoredCode.IsUnixHost ? hf.BindArchiveMember("ffmpeg") : hf.BindFirstOf(".exe")) { - var data = exe!.ReadAllBytes(); - //last chance. exiting, don't dump the new ffmpeg file if (exiting) return; - - DirectoryInfo parentDir = new(Path.GetDirectoryName(FFmpegService.FFmpegPath)!); - if (!parentDir.Exists) parentDir.Create(); - File.WriteAllBytes(FFmpegService.FFmpegPath, data); + exe!.GetStream().CopyTo(fs); + fs.Dispose(); if (OSTailoredCode.IsUnixHost) { OSTailoredCode.ConstructSubshell("chmod", $"+x {FFmpegService.FFmpegPath}", checkStdout: false).Start();