Git for Windows marks loose objects read-only. Match rm -rf semantics in * test cleanup without broadening production cbm_unlink behavior. */
| 94 | /* Git for Windows marks loose objects read-only. Match rm -rf semantics in |
| 95 | * test cleanup without broadening production cbm_unlink behavior. */ |
| 96 | static inline int th_unlink_force(const char *path) { |
| 97 | int result = cbm_unlink(path); |
| 98 | #ifdef _WIN32 |
| 99 | if (result != 0) { |
| 100 | wchar_t *wide = cbm_path_to_wide(path); |
| 101 | DWORD attributes = wide ? GetFileAttributesW(wide) : INVALID_FILE_ATTRIBUTES; |
| 102 | if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_READONLY) != 0U && |
| 103 | SetFileAttributesW(wide, attributes & ~((DWORD)FILE_ATTRIBUTE_READONLY))) { |
| 104 | result = cbm_unlink(path); |
| 105 | } |
| 106 | free(wide); |
| 107 | } |
| 108 | #endif |
| 109 | return result; |
| 110 | } |
| 111 | |
| 112 | /* Remove a file or directory tree recursively. Cross-platform rm -rf. */ |
| 113 | static inline int th_rmtree(const char *path) { |
no test coverage detected