1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | -- this package helps the others access the compiler static environment -- (i.e. all the configuration files) with system; --with unchecked_conversion; package body aada_compiler_configuration is -- map the system readlink() function function system_readlink(path: system.address; buf: system.address; bufsiz: integer) return integer; pragma import(C, system_readlink, "__gnat_readlink"); -- overload the function so we don't have to do the C string transformation -- every time we use it; we expect path to be the known path to the destination -- note that if status is <= 0 then the function failed (the file is probably not -- a symbolic link) procedure aada_readlink(path: in string; destination: out string; status: out integer) is p: string(1 .. path'length + 1); begin -- make the path a null terminated string p(1 .. path'length) := path; p(path'length + 1) := ascii.nul; status := system_readlink(path'Address, destination'address, destination'length); end; function aada_configuration_path return string is status: integer; app_path: string(1 .. 256); begin -- this is currently very specific to linux -- see: http://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe aada_readlink("/proc/self/exe", app_path, status); if status <= 0 then raise cannot_find_self_error; end if; -- status is the length of the string returned by the system readlink() function return app_path(1 .. status); end aada_configuration_path; end aada_compiler_configuration; |
Project | aada v1.0-338 (Project id #3) |
Process | Done (Last compiled on 2012/01/13 01:21:26) |
Description | Alexis Ada Compiler written in Ada (my first attempt was in C++ which is not correct for an Ada compiler.) |