Returns the directory this executable is running from */
| 443 | |
| 444 | /* Returns the directory this executable is running from */ |
| 445 | static const char *find_my_directory(const tal_t *ctx, const char *argv0) |
| 446 | { |
| 447 | /* find_my_abspath simply exits on failure, so never returns NULL. */ |
| 448 | const char *me = find_my_abspath(NULL, argv0); |
| 449 | |
| 450 | /*~ The caller just wants the directory we're in. |
| 451 | * |
| 452 | * Note the magic `take()` macro here: it annotates a pointer as "to |
| 453 | * be taken", and the recipient is expected to take ownership of the |
| 454 | * pointer. This improves efficiency because the recipient might |
| 455 | * choose to use or even keep it rather than make a copy (or it |
| 456 | * might just free it). |
| 457 | * |
| 458 | * Many CCAN and our own routines support this, but if you hand a |
| 459 | * `take()` to a routine which *doesn't* expect it, unfortunately you |
| 460 | * don't get a compile error (we have runtime detection for this |
| 461 | * case, however). |
| 462 | */ |
| 463 | return path_dirname(ctx, take(me)); |
| 464 | } |
| 465 | |
| 466 | /*~ This returns the PKGLIBEXEC path which is where binaries get installed. |
| 467 | * Note the `TAKES` annotation which indicates that the `my_path` parameter |
no test coverage detected