| 7312 | } |
| 7313 | |
| 7314 | static bool prepare_config_parent(const char *path) { |
| 7315 | if (!path || !path[0]) { |
| 7316 | return false; |
| 7317 | } |
| 7318 | char parent[CLI_BUF_1K]; |
| 7319 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 7320 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 7321 | return false; |
| 7322 | } |
| 7323 | char *slash = strrchr(parent, '/'); |
| 7324 | char *backslash = strrchr(parent, '\\'); |
| 7325 | if (backslash && (!slash || backslash > slash)) { |
| 7326 | slash = backslash; |
| 7327 | } |
| 7328 | if (!slash || slash == parent) { |
| 7329 | return slash != NULL; |
| 7330 | } |
| 7331 | *slash = '\0'; |
| 7332 | return cbm_mkdir_p(parent, CLI_OCTAL_PERM); |
| 7333 | } |
| 7334 | |
| 7335 | typedef struct { |
| 7336 | const char *label; |
no test coverage detected