MCPcopy Index your code
hub / github.com/git/git / create_directories

Function create_directories

entry.c:19–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "parallel-checkout.h"
18
19static void create_directories(const char *path, int path_len,
20 const struct checkout *state)
21{
22 char *buf = xmallocz(path_len);
23 int len = 0;
24
25 while (len < path_len) {
26 do {
27 buf[len] = path[len];
28 len++;
29 } while (len < path_len && path[len] != '/');
30 if (len >= path_len)
31 break;
32 buf[len] = 0;
33
34 /*
35 * For 'checkout-index --prefix=<dir>', <dir> is
36 * allowed to be a symlink to an existing directory,
37 * and we set 'state->base_dir_len' below, such that
38 * we test the path components of the prefix with the
39 * stat() function instead of the lstat() function.
40 */
41 if (has_dirs_only_path(buf, len, state->base_dir_len))
42 continue; /* ok, it is already a directory. */
43
44 /*
45 * If this mkdir() would fail, it could be that there
46 * is already a symlink or something else exists
47 * there, therefore we then try to unlink it and try
48 * one more time to create the directory.
49 */
50 if (mkdir(buf, 0777)) {
51 if (errno == EEXIST && state->force &&
52 !unlink_or_warn(buf) && !mkdir(buf, 0777))
53 continue;
54 die_errno("cannot create directory at '%s'", buf);
55 }
56 }
57 free(buf);
58}
59
60static void remove_subtree(struct strbuf *path)
61{

Callers 1

checkout_entry_caFunction · 0.85

Calls 4

xmalloczFunction · 0.85
has_dirs_only_pathFunction · 0.85
unlink_or_warnFunction · 0.85
die_errnoFunction · 0.85

Tested by

no test coverage detected