aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: 5dbf1fbc0b82c7e6c545fc02c296de53b644a0bd (plain)
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
42
43
44
45
46
47
48
49

## Here I Am!

This is an Ada wrapper applied to the
[Where Am I?](https://github.com/gpakosz/whereami) library by Gregory Pakosz.
As with the original C, this allows for easily locating where the running
executable or module is stored in the filesystem.

Note that this functionality is **not** something you can do with the Ada
standard library!

The `Command_Name` subprogram in `Ada.Command_Line` will only get you the
command used to invoke the executable, which might be a symlink and/or might
have had a platform-specific `$PATH` used to find it. The `Current_Directory`
and `Containing_Directory` subprograms in `Ada.Directories` will only get you
the current working directory. That may be completely different from where the
executable is located if an absolute or relative path was supplied with the
command or, again, a platform-specific `$PATH` was involved.

Of the options in the standard library the most reliable one would be to use
`Ada.Environment_Variables` and process each possible platform-specific `$PATH`
manually. But that still wouldn't resolve any symlinks or other shortcut files.



#### Building and Installation

If this was a dynamic library then the function to locate the current module
would always return the location of that shared object. On the other hand if
this was a static library then it wouldn't be possible to compile as part of a
dynamic libary.

Thus, to use this you should instead just copy the contents of `src` wholesale
to a suitable spot in your own project.

The `tests.gpr` project file can be used to build some very basic sanity checks
if desired.



#### Credits and Licensing

Ada wrapper code written by Jedidiah Barber and released into the public domain
as per `unlicense.txt`.

C code written by Gregory Pakosz and licensed under the WTFPL which lets you do
whatever you want, so it's basically public domain as well.