Ensure FFmpeg DL target is writable before downloading
This commit is contained in:
parent
542a0e08be
commit
736abf32ac
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue