Returns the directory this executable is running from */
| 521 | |
| 522 | /* Returns the directory this executable is running from */ |
| 523 | static const char *find_my_directory(const tal_t *ctx, const char *argv0) |
| 524 | { |
| 525 | /* find_my_abspath simply exits on failure, so never returns NULL. */ |
| 526 | const char *me = find_my_abspath(NULL, argv0); |
| 527 | |
| 528 | /*~ The caller just wants the directory we're in. |
| 529 | * |
| 530 | * Note the magic `take()` macro here: it annotates a pointer as "to |
| 531 | * be taken", and the recipient is expected to take ownership of the |
| 532 | * pointer. This improves efficiency because the recipient might |
| 533 | * choose to use or even keep it rather than make a copy (or it |
| 534 | * might just free it). |
| 535 | * |
| 536 | * Many CCAN and our own routines support this, but if you hand a |
| 537 | * `take()` to a routine which *doesn't* expect it, unfortunately you |
| 538 | * don't get a compile error (we have runtime detection for this |
| 539 | * case, however). |
| 540 | */ |
| 541 | return path_dirname(ctx, take(me)); |
| 542 | } |
| 543 | |
| 544 | /* How to get from abspath dir1 to abspath dir2? */ |
| 545 | static const char *relative(const tal_t *ctx, const char *dir1, const char *dir2) |
no test coverage detected