| 104 | // } |
| 105 | |
| 106 | void 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 | |
| 131 | void get_resouce_usage(struct rusage *r_usage) { |
| 132 | getrusage(RUSAGE_SELF, r_usage); |
no outgoing calls