summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Rodrigues Couto <gabriel@rodriguescouto.com.br>2016-02-23 13:10:54 -0300
committerGabriel Rodrigues Couto <gabriel@rodriguescouto.com.br>2016-02-23 13:10:54 -0300
commit67eb2fed8059813fbaf46fd96593d5d30e8b50bf (patch)
treeb690711d6143b58724a032ccd65e0f168c734a31
parentb63b070a8afc6dc654e655e760a2d42e755a0a5a (diff)
parent5878e4570c262f4260737f477cfcd44249fff519 (diff)
downloadphp-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.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/boot.php b/boot.php
index 5cfca7a..c7eb425 100644
--- a/boot.php
+++ b/boot.php
@@ -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);