| 809 | } |
| 810 | |
| 811 | static int text_delete_file(const char *path, const char *old_data, size_t old_len, |
| 812 | const text_file_snapshot_t *snapshot) { |
| 813 | #ifdef CBM_TEXT_EDIT_ENABLE_TEST_API |
| 814 | if (text_precommit_test_hook) { |
| 815 | text_precommit_test_hook(path, text_precommit_test_context); |
| 816 | } |
| 817 | #endif |
| 818 | if (text_snapshot_matches_path(path, old_data, old_len, snapshot) != TEXT_OK) { |
| 819 | return TEXT_ERROR; |
| 820 | } |
| 821 | #ifdef CBM_TEXT_EDIT_ENABLE_TEST_API |
| 822 | if (text_prepublish_test_hook) { |
| 823 | text_prepublish_test_hook(path, text_prepublish_test_context); |
| 824 | } |
| 825 | #endif |
| 826 | if (text_snapshot_matches_path(path, old_data, old_len, snapshot) != TEXT_OK) { |
| 827 | return TEXT_ERROR; |
| 828 | } |
| 829 | #ifdef _WIN32 |
| 830 | wchar_t *wide_path = cbm_utf8_to_wide(path); |
| 831 | if (!wide_path) { |
| 832 | return TEXT_ERROR; |
| 833 | } |
| 834 | BOOL removed = DeleteFileW(wide_path); |
| 835 | free(wide_path); |
| 836 | return removed ? TEXT_OK : TEXT_ERROR; |
| 837 | #else |
| 838 | if (unlink(path) != 0) { |
| 839 | return TEXT_ERROR; |
| 840 | } |
| 841 | return text_sync_parent_directory(path); |
| 842 | #endif |
| 843 | } |
| 844 | |
| 845 | #ifdef CBM_TEXT_EDIT_ENABLE_TEST_API |
| 846 | void cbm_text_set_precommit_hook_for_testing(cbm_text_precommit_test_hook_t hook, void *context) { |
no test coverage detected