| 7119 | } |
| 7120 | |
| 7121 | static bool prepare_config_parent(const char *path) { |
| 7122 | if (!path || !path[0]) { |
| 7123 | return false; |
| 7124 | } |
| 7125 | char parent[CLI_BUF_1K]; |
| 7126 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 7127 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 7128 | return false; |
| 7129 | } |
| 7130 | char *slash = strrchr(parent, '/'); |
| 7131 | char *backslash = strrchr(parent, '\\'); |
| 7132 | if (backslash && (!slash || backslash > slash)) { |
| 7133 | slash = backslash; |
| 7134 | } |
| 7135 | if (!slash || slash == parent) { |
| 7136 | return slash != NULL; |
| 7137 | } |
| 7138 | *slash = '\0'; |
| 7139 | return cbm_mkdir_p(parent, CLI_OCTAL_PERM); |
| 7140 | } |
| 7141 | |
| 7142 | typedef struct { |
| 7143 | const char *label; |
no test coverage detected