def close(self):
        """Close the file."""
        # ignore closing a closed file
        if not self._is_open():
            return

        # for raw io, all writes are flushed immediately
        if self.allow_update and not self.raw_io:
            self.flush()
            if self._filesystem.is_windows_fs and self._changed:
                self.file_object.st_mtime = time.time()
        if self._closefd:
            self._filesystem._close_open_file(self.filedes)
        else:
            self._filesystem.open_files[self.filedes].remove(self)
        if self.delete_on_close:
            self._filesystem.remove_object(self.get_object().path)