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