From ce51ce0b19a6ca90be4764028827e9e046c7470c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Szostak?= Date: Sat, 20 Apr 2024 15:30:12 +0200 Subject: [PATCH] Implemented checking if file even exists --- src/sillymachine.adb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sillymachine.adb b/src/sillymachine.adb index 5d9da1a..98f1c9b 100644 --- a/src/sillymachine.adb +++ b/src/sillymachine.adb @@ -1,6 +1,7 @@ with Ada.Text_IO; use Ada.Text_IO; with Ada.Sequential_IO; with Ada.Command_Line; use Ada.Command_Line; +with Ada.Directories; procedure sillymachine is type Byte is mod 256; @@ -8,7 +9,7 @@ procedure sillymachine is type ByteArr is array (Integer range <>) of Byte; F : Bin_IO.File_Type; - FileName : String (1 .. 255); + FileName : String (1 .. 255) := (others => ascii.nul); FileNameLength : Integer := 0; ValidHeader : ByteArr (0 .. 15); Arr : ByteArr (0 .. 15); @@ -62,4 +63,6 @@ begin Put_Line("Header passed"); << THE_END >> +exception + when Name_Error => New_Line(1); Put("Error: File '"); Put(FileName); Put_Line("' does not exist!"); New_Line(1); end sillymachine;