Close file (index=None -> close current file)
        Keep current file index unchanged (if current file
        that is being closed)
199439
def close_file(self, index=None, force=False):
        """"""
        current_index = self.get_stack_index()
        count = self.get_stack_count()

        if index is None:
            if count > 0:
                index = current_index
            else:
                self.find_widget.set_editor(None)
                return

        new_index = None
        if count > 1:
            if current_index == index:
                new_index = self._get_previous_file_index()
            else:
                new_index = current_index

        is_ok = force or self.save_if_changed(cancelable=True, index=index)
        if is_ok:
            finfo = self.data[index]
            self.threadmanager.close_threads(finfo)
            # Removing editor reference from outline explorer settings:
            if self.outlineexplorer is not None:
                self.outlineexplorer.remove_editor(finfo.editor.oe_proxy)

            filename = self.data[index].filename
            self.remove_from_data(index)
            finfo.editor.notify_close()

            # We pass self object ID as a QString, because otherwise it would
            # depend on the platform: long for 64bit, int for 32bit. Replacing
            # by long all the time is not working on some 32bit platforms
            # (see Issue 1094, Issue 1098)
            self.sig_close_file.emit(str(id(self)), filename)

            self.opened_files_list_changed.emit()
            self.update_code_analysis_actions.emit()
            self._refresh_outlineexplorer()
            self.refresh_file_dependent_actions.emit()
            self.update_plugin_title.emit()

            editor = self.get_current_editor()
            if editor:
                editor.setFocus()

            if new_index is not None:
                if index < new_index:
                    new_index -= 1
                self.set_stack_index(new_index)

            self.add_last_closed_file(finfo.filename)

        if self.get_stack_count() == 0 and self.create_new_file_if_empty:
            self.sig_new_file[()].emit()
            return False
        self.__modify_stack_title()
        return is_ok
64021
def close_open_fds(keep_files=[]):
    
    keep_fds = set()
    for file in keep_files:
        if isinstance(file, int):
            keep_fds.add(file)
        else:
            try:
                keep_fds.add(file.fileno())
            except Exception:
                pass

    for fd in os.listdir("/proc/self/fd"):
        fd = int(fd)
        if fd not in keep_fds:
            try:
                os.close(fd)
            except OSError:
                # irrelevant and expected
                # (the fd that was used by os.listdir() of course always fails)
                pass
404257
def close(self, filehandle):
        """"""
        with self.lock:
            if filehandle in self.files:
                self.files[filehandle] -= 1
                # trim the file cache
                index = 0
                size = len(self.past)
                while size > self.size and index < size:
                    filehandle = self.past[index]
                    if self.files[filehandle] == 0:
                        filehandle.close()
                        del self.files[filehandle]
                        del self.past[index]
                        size -= 1
                    else:
                        index += 1
1360464
def close(self):
        
        from .collection import Collection
        from .data._data import Channel, Data, Variable

        path = os.path.abspath(self.filepath) + "::"
        for key in list(Group._instances.keys()):
            if key.startswith(path):
                Group._instances.pop(key, None)

        if self.fid.valid > 0:
            # for some reason, the following file operations sometimes fail
            # this stops execution of the method, meaning that the tempfile is never removed
            # the following try case ensures that the tempfile code is always executed
            # ---Blaise 2018-01-08
            try:
                self.file.flush()
                try:
                    # Obtaining the file descriptor must be done prior to closing
                    fd = self.fid.get_vfd_handle()
                except (NotImplementedError, ValueError):
                    # only available with certain h5py drivers
                    # not needed if not available
                    pass

                self.file.close()
                try:
                    if fd:
                        os.close(fd)
                except OSError:
                    # File already closed, e.g.
                    pass
            except SystemError as e:
                warnings.warn("SystemError: {0}".format(e))
            finally:
                if hasattr(self, "_tmpfile"):
                    os.close(self._tmpfile[0])
                    os.remove(self._tmpfile[1])
1155241
def close(self, suppress_warning: bool = False) -> None:
		
		if self._file is None:
			if not suppress_warning:
				# Warn user that they're being paranoid
				# and should clean up their code
				logging.warn("Connection to %s is already closed", self.filename)
		else:
			self._file.close()
			self._file = None
		self.layers = None  # type: ignore
		self.ra = None  # type: ignore
		self.row_attrs = None  # type: ignore
		self.ca = None  # type: ignore
		self.col_attrs = None  # type: ignore
		self.row_graphs = None  # type: ignore
		self.col_graphs = None  # type: ignore
		self.shape = (0, 0)
		self._closed = True
1129737
def file_close(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/close' % object_id, input_params, always_retry=always_retry, **kwargs)
1312454
def close(self):
        
        if self.fileobj is None:
            return
        if self.mode == WRITE:
            self.close_member()
            self.fileobj = None
        elif self.mode == READ:
            self.fileobj = None
            
        if self.myfileobj:
            self.myfileobj.close()
            self.myfileobj = None
936230
def close(self):
        ''''''
        if self._connection:
            self._connection_file.close()
            self._connection_file = None
            self._connection.close()
            self._connection = None
122575
def _ensure_file_is_good(self, current_time):
        """"""
        if self._last_file_mapping_update and current_time - self._last_file_mapping_update <= self._stat_interval:
            return

        self._last_file_mapping_update = time.time()

        try:
            st = os.stat(self._filename)
        except EnvironmentError, err:
            if err.errno == errno.ENOENT:
                self._log_info('file removed')
                self.close()
                return
            raise

        fid = self.get_file_id(st)
        if fid != self._fid:
            self._log_info('file rotated')
            self.close()
        elif self._file.tell() > st.st_size:
            if st.st_size == 0 and self._ignore_truncate:
                self._logger.info("[{0}] - file size is 0 {1}. ".format(fid, self._filename) +
                                  "If you use another tool (i.e. logrotate) to truncate " +
                                  "the file, your application may continue to write to " +
                                  "the offset it last wrote later. In such a case, we'd " +
                                  "better do nothing here")
                return
            self._log_info('file truncated')
            self._update_file(seek_to_end=False)
        elif REOPEN_FILES:
            self._log_debug('file reloaded (non-linux)')
            position = self._file.tell()
            self._update_file(seek_to_end=False)
            if self.active:
                self._file.seek(position, os.SEEK_SET)
668998
def _close_pidfile(self):
        """"""
        if self._pid_fd is not None:
            os.close(self._pid_fd)
        try:
            os.remove(self.pidfile)
        except OSError as ex:
            if ex.errno != errno.ENOENT:
                raise
911627
def close(self):
        
        if callable(getattr(self._file, 'close', None)):
            self._iterator.close()
        self._iterator = None
        self._unconsumed = None
        self.closed = True
845484
def _Close(self):
    """"""
    self._cpio_archive_file_entry = None
    self._cpio_archive_file = None

    self._file_system.Close()
    self._file_system = None
199
def end(self, close_fileobj=True):
        """"""
        log.debug("in TftpContext.end - closing socket")
        self.sock.close()
        if close_fileobj and self.fileobj is not None and not self.fileobj.closed:
            log.debug("self.fileobj is open - closing")
            self.fileobj.close()
1329131
public void close() throws IOException {
        switch (state) {
            case READY:
                throw new IllegalStateException("File " + tempFile
                        + " hasn't been opened yet.");
            case CLOSED:
                throw new IllegalStateException("File " + tempFile
                        + " has been closed already.");
            default: // OPEN
                fileWriter.close();
                tempFile.renameTo(file);
                state = State.CLOSED;
        }
    }
830405
def close_all_but_this(self):
        """"""
        self.close_all_right()
        for i in range(0, self.get_stack_count()-1  ):
            self.close_file(0)
601846
def Close(self):
    
    if not self._is_open:
      raise IOError('Not opened.')

    if not self._is_cached:
      close_file_system = True
    elif self._resolver_context.ReleaseFileSystem(self):
      self._is_cached = False
      close_file_system = True
    else:
      close_file_system = False

    if close_file_system:
      self._Close()
      self._is_open = False
      self._path_spec = None
441722
public function close() {
        // Close the file handle if hasn't been closed already.
        if (is_resource($this->fhandle)) {
            fclose($this->fhandle);
            $this->fhandle = null;
        }
    }