MCPcopy Create free account
hub / github.com/ElementsProject/lightning / path_pushd

Function path_pushd

ccan/ccan/tal/path/path.c:72–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72struct path_pushd *path_pushd(const tal_t *ctx, const char *dir)
73{
74 struct path_pushd *old = tal(ctx, struct path_pushd);
75
76 if (!old)
77 return NULL;
78
79 if (unlikely(!dir) && taken(dir))
80 return tal_free(old);
81
82 if (!tal_add_destructor(old, pushd_destroy))
83 old = tal_free(old);
84 else {
85 old->fd = open(".", O_RDONLY);
86 if (old->fd < 0)
87 old = tal_free(old);
88 else if (chdir(dir) != 0)
89 old = tal_free(old);
90 }
91
92 if (taken(dir))
93 tal_free(dir);
94 return old;
95}
96
97bool path_popd(struct path_pushd *olddir)
98{

Callers 1

path_canonFunction · 0.70

Calls 4

takenFunction · 0.85
tal_freeFunction · 0.85
path_cwdFunction · 0.85
is_takenFunction · 0.85

Tested by

no test coverage detected