| 7374 | } |
| 7375 | |
| 7376 | static bool prepare_config_parent(const char *path) { |
| 7377 | if (!path || !path[0]) { |
| 7378 | return false; |
| 7379 | } |
| 7380 | char parent[CLI_BUF_1K]; |
| 7381 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 7382 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 7383 | return false; |
| 7384 | } |
| 7385 | char *slash = strrchr(parent, '/'); |
| 7386 | char *backslash = strrchr(parent, '\\'); |
| 7387 | if (backslash && (!slash || backslash > slash)) { |
| 7388 | slash = backslash; |
| 7389 | } |
| 7390 | if (!slash || slash == parent) { |
| 7391 | return slash != NULL; |
| 7392 | } |
| 7393 | *slash = '\0'; |
| 7394 | return cbm_mkdir_p(parent, CLI_OCTAL_PERM); |
| 7395 | } |
| 7396 | |
| 7397 | typedef struct { |
| 7398 | const char *label; |
no test coverage detected