| 171 | /* ── Save ────────────────────────────────────────────────────── */ |
| 172 | |
| 173 | static bool config_parent_directory(const char *path, char *directory, size_t directory_size) { |
| 174 | int written = snprintf(directory, directory_size, "%s", path ? path : ""); |
| 175 | if (written <= 0 || (size_t)written >= directory_size) { |
| 176 | return false; |
| 177 | } |
| 178 | char *slash = strrchr(directory, '/'); |
| 179 | char *backslash = strrchr(directory, '\\'); |
| 180 | if (backslash && (!slash || backslash > slash)) { |
| 181 | slash = backslash; |
| 182 | } |
| 183 | if (!slash) { |
| 184 | return snprintf(directory, directory_size, ".") == 1; |
| 185 | } |
| 186 | if (slash == directory) { |
| 187 | slash[1] = '\0'; |
| 188 | } else { |
| 189 | *slash = '\0'; |
| 190 | } |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | #ifdef _WIN32 |
| 195 | static volatile LONG g_config_temp_sequence = 0; |
no outgoing calls
no test coverage detected