| 7225 | } |
| 7226 | |
| 7227 | static bool prepare_config_parent(const char *path) { |
| 7228 | if (!path || !path[0]) { |
| 7229 | return false; |
| 7230 | } |
| 7231 | char parent[CLI_BUF_1K]; |
| 7232 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 7233 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 7234 | return false; |
| 7235 | } |
| 7236 | char *slash = strrchr(parent, '/'); |
| 7237 | char *backslash = strrchr(parent, '\\'); |
| 7238 | if (backslash && (!slash || backslash > slash)) { |
| 7239 | slash = backslash; |
| 7240 | } |
| 7241 | if (!slash || slash == parent) { |
| 7242 | return slash != NULL; |
| 7243 | } |
| 7244 | *slash = '\0'; |
| 7245 | return cbm_mkdir_p(parent, CLI_OCTAL_PERM); |
| 7246 | } |
| 7247 | |
| 7248 | typedef struct { |
| 7249 | const char *label; |
no test coverage detected