MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / create_dir

Function create_dir

libCacheSim/utils/mysys.c:106–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104// }
105
106void create_dir(char *dir_path) {
107 char temp[1024];
108 snprintf(temp, sizeof(temp), "%s", dir_path);
109 size_t len = strlen(temp);
110 if (temp[len - 1] == '/') {
111 temp[len - 1] = '\0';
112 }
113 for (char *p = temp + 1; *p; p++) {
114 if (*p == '/') {
115 *p = '\0';
116 if (access(temp, F_OK) == -1) {
117 if (mkdir(temp, 0777) == -1) {
118 perror("mkdir error");
119 }
120 }
121 *p = '/';
122 }
123 }
124 if (access(temp, F_OK) == -1) {
125 if (mkdir(temp, 0777) == -1) {
126 perror("mkdir error");
127 }
128 }
129}
130
131void get_resouce_usage(struct rusage *r_usage) {
132 getrusage(RUSAGE_SELF, r_usage);

Callers 3

test_create_dirFunction · 0.85
mainFunction · 0.85
simulateFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_create_dirFunction · 0.68