| 7163 | } |
| 7164 | |
| 7165 | static bool prepare_config_parent(const char *path) { |
| 7166 | if (!path || !path[0]) { |
| 7167 | return false; |
| 7168 | } |
| 7169 | char parent[CLI_BUF_1K]; |
| 7170 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 7171 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 7172 | return false; |
| 7173 | } |
| 7174 | char *slash = strrchr(parent, '/'); |
| 7175 | char *backslash = strrchr(parent, '\\'); |
| 7176 | if (backslash && (!slash || backslash > slash)) { |
| 7177 | slash = backslash; |
| 7178 | } |
| 7179 | if (!slash || slash == parent) { |
| 7180 | return slash != NULL; |
| 7181 | } |
| 7182 | *slash = '\0'; |
| 7183 | return cbm_mkdir_p(parent, CLI_OCTAL_PERM); |
| 7184 | } |
| 7185 | |
| 7186 | typedef struct { |
| 7187 | const char *label; |
no test coverage detected