From 07da11fe40d4547e265a122a072daacf1b5f893f Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sun, 26 Feb 2023 16:56:32 +0100 Subject: [PATCH] Bugfix FS opening an invalid filepath --- Capy64/Runtime/Libraries/FileSystem.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Capy64/Runtime/Libraries/FileSystem.cs b/Capy64/Runtime/Libraries/FileSystem.cs index e70f38b..c946444 100644 --- a/Capy64/Runtime/Libraries/FileSystem.cs +++ b/Capy64/Runtime/Libraries/FileSystem.cs @@ -555,12 +555,20 @@ public class FileSystem : IComponent } } - var fileStream = File.Open(path, fileMode, fileAccess, FileShare.ReadWrite | FileShare.Delete); + try + { + var fileStream = File.Open(path, fileMode, fileAccess, FileShare.ReadWrite | FileShare.Delete); - ObjectManager.PushObject(L, fileStream); - L.SetMetaTable(FileHandle.ObjectType); + ObjectManager.PushObject(L, fileStream); + L.SetMetaTable(FileHandle.ObjectType); - return 1; + return 1; + } + catch (Exception ex) + { + L.Error(ex.Message); + } + return 0; } }