diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-04-06 12:50:24 +1200 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-04-06 12:50:24 +1200 |
commit | aa322806bbf375505c9a67603768af83cc443e2d (patch) | |
tree | 768c462740bb956aeb72c347395b097306bfb2d2 /src | |
parent | 10286c0b22f3111e74bf699f224a4e8061626d4c (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/here_i_am.adb | 17 | ||||
-rw-r--r-- | src/here_i_am.ads | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/here_i_am.adb b/src/here_i_am.adb index 0117fc3..879e07e 100644 --- a/src/here_i_am.adb +++ b/src/here_i_am.adb @@ -6,9 +6,14 @@ with + Ada.Assertions, Interfaces.C.Strings, System.Storage_Elements; +use type + + Interfaces.C.int; + package body Here_I_Am is @@ -46,12 +51,16 @@ package body Here_I_Am is wai_getExecutablePath (Interfaces.C.Strings.Null_Ptr, 0, Null_Pointer); Data_Buffer : aliased Interfaces.C.char_array := (1 .. Interfaces.C.size_t (Path_Length) => Interfaces.C.nul); - Ignore : constant Interfaces.C.int := wai_getExecutablePath + Code : constant Interfaces.C.int := wai_getExecutablePath (Interfaces.C.Strings.To_Chars_Ptr (Data_Buffer'Unchecked_Access), Path_Length, Null_Pointer); begin + pragma Assert (Code >= 0); return Interfaces.C.To_Ada (Data_Buffer, False); + exception + when Ada.Assertions.Assertion_Error => raise Where_Is_Error with + "wai_getExecutablePath returned int value of " & Interfaces.C.int'Image (Code); end Executable; @@ -62,12 +71,16 @@ package body Here_I_Am is wai_getModulePath (Interfaces.C.Strings.Null_Ptr, 0, Null_Pointer); Data_Buffer : aliased Interfaces.C.char_array := (1 .. Interfaces.C.size_t (Path_Length) => Interfaces.C.nul); - Ignore : constant Interfaces.C.int := wai_getModulePath + Code : constant Interfaces.C.int := wai_getModulePath (Interfaces.C.Strings.To_Chars_Ptr (Data_Buffer'Unchecked_Access), Path_Length, Null_Pointer); begin + pragma Assert (Code >= 0); return Interfaces.C.To_Ada (Data_Buffer, False); + exception + when Ada.Assertions.Assertion_Error => raise Where_Is_Error with + "wai_getModulePath returned int value of " & Interfaces.C.int'Image (Code); end Module; diff --git a/src/here_i_am.ads b/src/here_i_am.ads index 7276a9a..367ac57 100644 --- a/src/here_i_am.ads +++ b/src/here_i_am.ads @@ -7,6 +7,9 @@ package Here_I_Am is + Where_Is_Error : exception; + + -- Provides the full name and path of the running executable function Executable return String; |