| 85 | } |
| 86 | |
| 87 | [[nodiscard]] |
| 88 | static GErrorResult<> copy_source_file_to_coverage_output( |
| 89 | GFile* source_file, GFile* destination_file) { |
| 90 | /* We need to recursively make the directory we want to copy to, as |
| 91 | * g_file_copy doesn't do that */ |
| 92 | Gjs::AutoError error; |
| 93 | Gjs::AutoUnref<GFile> destination_dir{g_file_get_parent(destination_file)}; |
| 94 | if (!g_file_make_directory_with_parents(destination_dir, nullptr, |
| 95 | error.out())) { |
| 96 | if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_EXISTS)) |
| 97 | return Err(error.release()); |
| 98 | error.reset(); |
| 99 | } |
| 100 | |
| 101 | if (!g_file_copy(source_file, destination_file, G_FILE_COPY_OVERWRITE, |
| 102 | nullptr, nullptr, nullptr, error.out())) |
| 103 | return Err(error.release()); |
| 104 | return Ok{}; |
| 105 | } |
| 106 | |
| 107 | // This function will strip a URI scheme and return the string with the URI |
| 108 | // scheme stripped or nullptr if the path was not a valid URI |
no test coverage detected