bool_t FSFH_release_window(FSFileHandle *self, FileWindow *window) { if ( !SI_unmap(self, window->buf, window->len) ) { return false; } FileWindow_Set_Window(window, NULL, 0, 0); return true; }
bool_t FSFH_close(FSFileHandle *self) { // On 64-bit systems, cancel the whole-file mapping. if (IS_64_BIT && (self->flags & FH_READ_ONLY) && self->buf != NULL) { if (!SI_unmap(self, self->buf, self->len)) { return false; } self->buf = NULL; } // Close system-specific handles. if (self->fd) { if (close(self->fd)) { Err_set_error(Err_new(CB_newf("Failed to close file: %s", strerror(errno)))); return false; } self->fd = 0; } #if (defined(CHY_HAS_WINDOWS_H) && !defined(CHY_HAS_SYS_MMAN_H)) if (self->win_fhandle) { if (!SI_close_win_handles(self)) { return false; } } #endif return true; }
bool FSFH_release_window(FSFileHandle *self, FileWindow *window) { char *buf = FileWindow_Get_Buf(window); int64_t len = FileWindow_Get_Len(window); if (!SI_unmap(self, buf, len)) { return false; } FileWindow_Set_Window(window, NULL, 0, 0); return true; }