Called by libcurl when it wants to change the file descriptors
        it cares about.
347639
def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None:
        
        event_map = {
            pycurl.POLL_NONE: ioloop.IOLoop.NONE,
            pycurl.POLL_IN: ioloop.IOLoop.READ,
            pycurl.POLL_OUT: ioloop.IOLoop.WRITE,
            pycurl.POLL_INOUT: ioloop.IOLoop.READ | ioloop.IOLoop.WRITE,
        }
        if event == pycurl.POLL_REMOVE:
            if fd in self._fds:
                self.io_loop.remove_handler(fd)
                del self._fds[fd]
        else:
            ioloop_event = event_map[event]
            # libcurl sometimes closes a socket and then opens a new
            # one using the same FD without giving us a POLL_NONE in
            # between.  This is a problem with the epoll IOLoop,
            # because the kernel can tell when a socket is closed and
            # removes it from the epoll automatically, causing future
            # update_handler calls to fail.  Since we can't tell when
            # this has happened, always use remove and re-add
            # instead of update.
            if fd in self._fds:
                self.io_loop.remove_handler(fd)
            self.io_loop.add_handler(fd, self._handle_events, ioloop_event)
            self._fds[fd] = ioloop_event
389907
def _fileobj_to_fd(fileobj):
    
    if isinstance(fileobj, int):
        fd = fileobj
    else:
        try:
            fd = int(fileobj.fileno())
        except (AttributeError, TypeError, ValueError):
            raise ValueError("Invalid file object: {0!r}".format(fileobj))
    if fd < 0:
        raise ValueError("Invalid file descriptor: {0}".format(fd))
    return fd
683419
static void modifyProfiles(File destination, Map<String, Profile> modifications) {
        final boolean inPlaceModify = destination.exists();
        File stashLocation = null;

        // Stash the original file, before we apply the changes
        if (inPlaceModify) {
            boolean stashed = false;

            try {
                // We can't use File.createTempFile, since it will always create
                // that file no matter what, and File.reNameTo does not allow
                // the destination to be an existing file
                stashLocation = new File(destination.getParentFile(),
                        destination.getName() + ".bak."
                                + UUID.randomUUID().toString());
                stashed = destination.renameTo(stashLocation);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(String
                            .format("The original credentials file is stashed to loaction (%s).",
                                    stashLocation.getAbsolutePath()));
                }

            } finally {
                if (!stashed) {
                    throw new SdkClientException(
                            "Failed to stash the existing credentials file " +
                            "before applying the changes.");
                }
            }
        }

        OutputStreamWriter writer = null;
        try {
            writer = new OutputStreamWriter(new FileOutputStream(destination), StringUtils.UTF8);
            ProfilesConfigFileWriterHelper writerHelper = new ProfilesConfigFileWriterHelper(writer, modifications);

            if (inPlaceModify) {
                Scanner existingContent = new Scanner(stashLocation, StringUtils.UTF8.name());
                writerHelper.writeWithExistingContent(existingContent);
            } else {
                writerHelper.writeWithoutExistingContent();
            }

            // Make sure the output is valid and can be loaded by the loader
            new ProfilesConfigFile(destination);

            if ( inPlaceModify && !stashLocation.delete() ) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(String
                            .format("Successfully modified the credentials file. But failed to " +
                                    "delete the stashed copy of the original file (%s).",
                                    stashLocation.getAbsolutePath()));
                }
            }

        } catch (Exception e) {
            // Restore the stashed file
            if (inPlaceModify) {
                boolean restored = false;

                try {
                    // We don't really care about what destination.delete()
                    // returns, since the file might not have been created when
                    // the error occurred.
                    if ( !destination.delete() ) {
                        LOG.debug("Unable to remove the credentials file "
                                + "before restoring the original one.");
                    }
                    restored = stashLocation.renameTo(destination);
                } finally {
                    if (!restored) {
                        throw new SdkClientException(
                                "Unable to restore the original credentials file. " +
                                "File content stashed in " + stashLocation.getAbsolutePath());
                    }
                }
            }

            throw new SdkClientException(
                    "Unable to modify the credentials file. " +
                    "(The original file has been restored.)",
                    e);

        } finally {
            try {
                if (writer != null) writer.close();
            } catch (IOException e) {}
        }
    }
1289439
def adjustFiles(rec, op):  # type: (Any, Union[Callable[..., Any], partial[Any]]) -> None
    """"""

    if isinstance(rec, MutableMapping):
        if rec.get("class") == "File":
            rec["path"] = op(rec["path"])
        for d in rec:
            adjustFiles(rec[d], op)
    if isinstance(rec, MutableSequence):
        for d in rec:
            adjustFiles(d, op)
685602
private int getFileDescriptor() throws IOException {
		final int fd = SharedSecrets.getJavaIOFileDescriptorAccess().get(getFD());

        if(fd < 1)
            throw new IOException("failed to get POSIX file descriptor!");

        return fd;
    }
1079785
def update(sc, filename, asset_id):
    '''
    
    '''
    addresses = []
    with open(filename) as hostfile:
        for line in hostfile.readlines():
            addresses.append(line.strip('\n'))
    sc.asset_update(asset_id, dns=addresses)
1045552
def update(cls):
        
        ifaddrs = getifaddrs()
        # Create new interfaces
        for ifname in ifaddrs.keys():
            if filter(ifname.startswith, cls.NAME_FILTER):
                cls.objects.get_or_create(name=ifname)

        # Delete no longer existing ones
        cls.objects.exclude(name__in=ifaddrs.keys()).delete()
200059
def _parse_file_modify(self, info):
        
        params = info.split(b' ', 2)
        path = self._path(params[2])
        mode = self._mode(params[0])
        if params[1] == b'inline':
            dataref = None
            data = self._get_data(b'filemodify')
        else:
            dataref = params[1]
            data = None
        return commands.FileModifyCommand(path, mode, dataref,
            data)
405838
def change(file)
      if file.is_a?(Ichiban::HelperFile) or file.is_a?(Ichiban::ModelFile)
        delete_all
        load_all
        Ichiban.logger.reload(file.abs)
      end
    end
1287984
def _properties_changed(self,
                            object_path,
                            interface_name,
                            changed_properties,
                            invalidated_properties):
        
        # update device state:
        old_state = deepcopy(self._objects[object_path])
        for property_name in invalidated_properties:
            del self._objects[object_path][interface_name][property_name]
        for key, value in changed_properties.items():
            self._objects[object_path][interface_name][key] = value
        new_state = self._objects[object_path]
        # detect changes and trigger events:
        if interface_name == Interface['Drive']:
            self._detect_toggle(
                'has_media',
                self.get(object_path, old_state),
                self.get(object_path, new_state),
                'media_added', 'media_removed')
        elif interface_name == Interface['Filesystem']:
            self._detect_toggle(
                'is_mounted',
                self.get(object_path, old_state),
                self.get(object_path, new_state),
                'device_mounted', 'device_unmounted')
        self.trigger('device_changed',
                     self.get(object_path, old_state),
                     self.get(object_path, new_state))
663258
def can_rename(self):
        # type: (LocalSourcePaths) -> bool
        
        return len(self._paths) == 1 and (
            self._paths[0].is_file() or
            blobxfer.models.upload.LocalSourcePath.is_stdin(
                str(self._paths[0]))
        )
124213
def cleanup_all_temporary_files(self):
        # type: (Descriptor) -> None
        
        # delete local file
        try:
            self.final_path.unlink()
        except OSError:
            pass
        # iterate unchecked chunks and delete
        for key in self._unchecked_chunks:
            ucc = self._unchecked_chunks[key]['ucc']
            if ucc.temp:
                try:
                    ucc.file_path.unlink()
                except OSError:
                    pass
154718
function (args, callback) {
        if (ternserver) {
          ternserver.request({
              query: {
                type: "rename",  //$NON-NLS-1$
                file: args.meta.location,
                end: args.params.offset,
                newName: args.newname
              },
              files: args.files
            },
            function (error, changes) {
              if (error) {
                callback({
                  request: 'rename',
                  error: typeof error === 'string' ? error : error.message,
                  message: Messages['failedRenameTern']
                }); //$NON-NLS-1$
              } else if (changes && Array.isArray(changes.changes)) {
                callback({request: 'rename', changes: changes}); //$NON-NLS-1$
              } else {
                callback({request: 'rename', changes: []}); //$NON-NLS-1$
              }
            });
        } else {
          callback({request: 'rename', message: Messages['failedRenameNoServer']}); //$NON-NLS-1$
        }
      }
1362519
function filesPatch(oldFile, newFile, options) {
  let { diff, toFile } = utils;
  let opts = options || {};

  oldFile = toFile(oldFile, options);
  newFile = toFile(newFile, options);

  let nameA = oldFile.relative;
  let nameB = newFile.relative;

  let strA = oldFile.contents.toString();
  let strB = newFile.contents.toString();

  return diff.createTwoFilesPatch(nameA, nameB, strA, strB, opts.oldHeader, opts.newHeader, opts);
}
1198311
function fileChanges(subject, options) {
    const operators = [
        {
            option: "reloadThrottle",
            fnName: "throttle"
        },
        {
            option: "reloadDelay",
            fnName: "delay"
        }
    ];

    const scheduler = options.getIn(["debug", "scheduler"]);

    /**
     * Create a stream buffered/debounced stream of events
     */
    const initial = getAggregatedDebouncedStream(subject, options, scheduler);

    return applyOperators(operators, initial, options, scheduler)
        .map(function(items) {
            const paths = items.map(x => x.path);

            if (
                utils.willCauseReload(paths, options.get("injectFileTypes").toJS())
            ) {
                return {
                    type: "reload",
                    files: items
                };
            }
            return {
                type: "inject",
                files: items
            };
        })
}
396653
def rescan(self):
        
        if not self.attached:
            return
        dprint(5, "starting rescan")
        newstuff = {};  # this accumulates names of new or changed files. Keys are paths, values are 'quiet' flag.
        # store timestamp of scan
        self.last_scan_timestamp = time.time()
        # go through watched files/directories, check for mtime changes
        for path, watcher in list(self.watchers.items()):
            # get list of new files from watcher
            newfiles = watcher.newFiles()
            # None indicates access error, so drop it from watcher set
            if newfiles is None:
                if watcher.survive_deletion:
                    dprintf(5, "access error on %s, but will still be watched\n", watcher.path)
                else:
                    dprintf(2, "access error on %s, will no longer be watched\n", watcher.path)
                    del self.watchers[path]
                if not watcher.disappeared:
                    self.emit(SIGNAL("disappearedFile"), path)
                    watcher.disappeared = True
                continue
            dprintf(5, "%s: %d new file(s)\n", watcher.path, len(newfiles))
            # if a file has its own watcher, and is independently reported by a directory watcher, skip the directory's
            # version and let the file's watcher report it. Reason for this is that the file watcher may have a more
            # up-to-date timestamp, so we trust it over the dir watcher.
            newfiles = [p for p in newfiles if p is path or p not in self.watchers]
            # skip files in self._unwatched_paths
            newfiles = [filename for filename in newfiles if
                        self._watching_state.get(os.path.dirname(filename)) > Purr.UNWATCHED]
            # Now go through files and add them to the newstuff dict
            for newfile in newfiles:
                # if quiet flag is explicitly set on watcher, enforce it
                # if not pouncing on directory, also add quietly
                if watcher.quiet or self._watching_state.get(os.path.dirname(newfile)) < Purr.POUNCE:
                    quiet = True
                # else add quietly if file is not in the quiet patterns
                else:
                    quiet = matches_patterns(os.path.basename(newfile), self._quiet_patterns)
                # add file to list of new products. Since a file may be reported by multiple
                # watchers, make the quiet flag a logical AND of all the quiet flags (i.e. DP will be
                # marked as quiet only if all watchers report it as quiet).
                newstuff[newfile] = quiet and newstuff.get(newfile, True)
                dprintf(4, "%s: new data product, quiet=%d (watcher quiet: %s)\n", newfile, quiet, watcher.quiet)
                # add a watcher for this file to the temp_watchers list. this is used below
                # to detect renamed and deleted files
                self.temp_watchers[newfile] = Purrer.WatchedFile(newfile)
        # now, go through temp_watchers to see if any newly pounced-on files have disappeared
        for path, watcher in list(self.temp_watchers.items()):
            # get list of new files from watcher
            if watcher.newFiles() is None:
                dprintf(2, "access error on %s, marking as disappeared", watcher.path)
                del self.temp_watchers[path]
                self.emit(SIGNAL("disappearedFile"), path)
        # if we have new data products, send them to the main window
        return self.makeDataProducts(iter(newstuff.items()))
1290290
function(callback) {
            // Optional permission modification
            if (disablePerms) {
              callback();
              return;
            }
            
            grunt.verbose.writeln('changing file perms...');

            // 511 = 0777 octal
            ftpout.raw.site('chmod', (file.mode & 511).toString(8), file.dest, function(err) {
              // Windows and some hosts don't implement the CHMOD site extension
              if (err && err.code !== 502 && err.code !== 504) {
                done(err);
                return;
              }

              grunt.verbose.writeln('done changing perms');
              callback();
            });
          }