// directory-relative cleanup reaches the deliberately over-PATH_MAX fixture filename. module hookfixtures import os #include #include #include fn C.unlinkat(i32, &char, i32) i32 pub fn deep_directory(root string) string { return root + ('/' + 'd'.repeat(190)).repeat(20) } pub fn long_filename() string { return 'f'.repeat(232) + '.hook' } pub fn cleanup_long_paths(base string) ! { for backend in ['old', 'native', 'public'] { directory := deep_directory(os.join_path(base, 'long-hook-file', backend, 'root')) fd := C.open(unsafe { &char(directory.str) }, C.O_RDONLY | C.O_DIRECTORY | C.O_CLOEXEC) if fd < 0 { if C.errno == C.ENOENT { continue } return os.last_error() } defer { if C.close(fd) != 0 { eprintln(os.last_error()) } } name := long_filename() if C.unlinkat(fd, unsafe { &char(name.str) }, 0) != 0 && C.errno != C.ENOENT { return os.last_error() } } }