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

Function path_pushd

ccan/ccan/tal/path/path.c:79–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

path_canonFunction · 0.70

Calls 3

takenFunction · 0.85
tal_freeFunction · 0.85
path_cwdFunction · 0.85

Tested by

no test coverage detected