diff options
author | Gabriel Rodrigues Couto <gabriel@rodriguescouto.com.br> | 2016-02-23 13:10:54 -0300 |
---|---|---|
committer | Gabriel Rodrigues Couto <gabriel@rodriguescouto.com.br> | 2016-02-23 13:10:54 -0300 |
commit | 67eb2fed8059813fbaf46fd96593d5d30e8b50bf (patch) | |
tree | b690711d6143b58724a032ccd65e0f168c734a31 | |
parent | b63b070a8afc6dc654e655e760a2d42e755a0a5a (diff) | |
parent | 5878e4570c262f4260737f477cfcd44249fff519 (diff) | |
download | php-terminal-gameboy-emulator-67eb2fed8059813fbaf46fd96593d5d30e8b50bf.zip php-terminal-gameboy-emulator-67eb2fed8059813fbaf46fd96593d5d30e8b50bf.tar.gz php-terminal-gameboy-emulator-67eb2fed8059813fbaf46fd96593d5d30e8b50bf.tar.bz2 |
Merge pull request #16 from henriquemoody/file_check
Check if ROM exists before use it
-rw-r--r-- | boot.php | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,6 +1,6 @@ <?php -require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__.'/vendor/autoload.php'; use GameBoy\Canvas\TerminalCanvas; use GameBoy\Core; @@ -15,7 +15,12 @@ if (count($argv) < 2) { throw new RuntimeException('You need to pass the ROM file name (Ex: drmario.rom)'); } -$rom = file_get_contents('roms/' . $argv[1]); +$filename = 'roms/'.$argv[1]; +if (!file_exists($filename)) { + throw new RuntimeException(sprintf('"%s" does not exist', $filename)); +} + +$rom = file_get_contents($filename); $canvas = new TerminalCanvas(); $core = new Core($rom, $canvas); |