Stopped errors happening when trying to load a graphic without a filename

This commit is contained in:
Maruno17
2021-04-08 22:28:05 +01:00
parent 327d0de334
commit 614e0ed9a2
2 changed files with 152 additions and 151 deletions

View File

@@ -251,18 +251,19 @@ end
# Gets at least the first byte of a file. Doesn't check RTP, but does check
# encrypted archives.
def pbGetFileChar(file)
file = canonicalize(file)
canon_file = canonicalize(file)
if !safeExists?("./Game.rgssad")
return nil if !safeExists?(file)
return nil if !safeExists?(canon_file)
return nil if file.last == '/' # Is a directory
begin
File.open(file,"rb") { |f| return f.read(1) } # read one byte
File.open(canon_file, "rb") { |f| return f.read(1) } # read one byte
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES, Errno::EISDIR
return nil
end
end
str = nil
begin
str = load_data(file, true)
str = load_data(canon_file, true)
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES, Errno::EISDIR, RGSSError, MKXPError
str = nil
end