MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / th_unlink_force

Function th_unlink_force

tests/test_helpers.h:96–110  ·  view source on GitHub ↗

Git for Windows marks loose objects read-only. Match rm -rf semantics in * test cleanup without broadening production cbm_unlink behavior. */

Source from the content-addressed store, hash-verified

94/* Git for Windows marks loose objects read-only. Match rm -rf semantics in
95 * test cleanup without broadening production cbm_unlink behavior. */
96static 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. */
113static inline int th_rmtree(const char *path) {

Callers 1

th_rmtreeFunction · 0.85

Calls 2

cbm_unlinkFunction · 0.85
cbm_path_to_wideFunction · 0.85

Tested by

no test coverage detected