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