Seeking to end of the file by walking through all clusters
507695
private static Pair<Cluster, Cluster> getTwoLastClusters(@NotNull VirtualFileSystem vfs,
                                                             @NotNull final Transaction txn,
                                                             @NotNull final File file) {
        // todo: seek to end of file without loading all clusters
        try (ClusterIterator iterator = new ClusterIterator(vfs, txn, file)) {
            Cluster prevCluster = null;
            Cluster currCluster = null;
            while (iterator.hasCluster()) {
                prevCluster = currCluster;
                currCluster = iterator.getCurrent();
                iterator.moveToNext();
            }
            return new Pair<>(prevCluster, currCluster);
        }
    }
790199
def walk(self, top, topdown=True, ignore_file_handler=None):
        

        def onerror(e):
            raise e

        for root, dirs, files in dvc_walk(
            os.path.abspath(top),
            topdown=topdown,
            onerror=onerror,
            ignore_file_handler=ignore_file_handler,
        ):
            yield os.path.normpath(root), dirs, files
1012354
def _rescan(self, skip_to_end = True):
      """"""
      # Get listing of matching files.
      paths = []
      for single_glob in self._globspec:
          paths.extend(glob.glob(single_glob))

      # Remove files that don't appear in the new list.
      for path in self._tailedfiles.keys():
         if path not in paths:
            self._tailedfiles[path]._close()
            del self._tailedfiles[path]

      # Add any files we don't have open yet.
      for path in paths:
         try:
            # If the file has been rotated, reopen it.
            if self._tailedfiles[path].hasBeenRotated():
               # If it can't be reopened, close it.
               if not self._tailedfiles[path].reopen():
                  del self._tailedfiles[path]
         except KeyError:
            # Open a file that we haven't seen yet.
            self._tailedfiles[path] = TailedFile(path, skip_to_end = skip_to_end, offset = self._offsets.get(path, 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()
469056
def finish(self):
    
    if self.proc is None:
      return None
    self.proc.stdin.close()
    for thread in (self._out_thread, self._err_thread):
      thread.join()
    (out, err) = [
        b"".join(chunks) for chunks in (self._out_chunks, self._err_chunks)
    ]
    self.proc.stdout.close()
    self.proc.stderr.close()
    if self.proc.returncode:
      err = "\n".join([" ".join(self.cmd), err.decode("utf8")])
      raise IOError(err)
    del self.proc
    self.proc = None
    return out
1259391
private void setEndFileMarkerFile(String fileName) {
    int fileIndex = parseFileIndex(fileName);
    if (endFileNumber == -1) {
      // First time finding the end-marker file.
      endFileNumber = fileIndex;
      logger.atInfo().log("Found end-marker file '%s' with index %s", fileName, endFileNumber);

      // Sanity-check known filenames against the endFileNumber.
      for (String knownFile : knownFileSet) {
        int knownFileIndex = parseFileIndex(knownFile);
        Preconditions.checkState(
            knownFileIndex <= endFileNumber,
            "Found known file '%s' with index %s, which isn't less than or "
                + "equal to than endFileNumber %s!",
            knownFile, knownFileIndex, endFileNumber);
      }
    } else {
      // If we found it before, make sure the file we're looking at has the same index.
      Preconditions.checkState(fileIndex == endFileNumber,
          "Found new end-marker file '%s' with index %s but already have endFileNumber %s!",
          fileName, fileIndex, endFileNumber);
    }
  }
1302909
def end_output (self, **kwargs):
        """"""
        self.xml_endtag(u"graph")
        self.xml_endtag(u"GraphXML")
        self.xml_end_output()
        self.close_fileoutput()
553347
def end_document implicit_end = !streaming?
      @last.implicit_end = implicit_end
      n = pop
      set_end_location(n)
      n
    end
805656
def cleanup(self):
        
        if getattr(self._finalizer, "detach", None) and self._finalizer.detach():
            if os.path.exists(self.path):
                try:
                    rmtree(self.path)
                except OSError:
                    pass
                else:
                    self.path = None
912378
function complete() {
  quit();

  const deleteQueue = [];
  fs.readdir(paths.output, (err, files) => {
    if (files) {
      // lookup array for quick search inside existing component names
      const componentsLookup = components.map(item => {
        return slugify(item.meta.name);
      });

      // loop over files
      for (let i = 0, l = files.length; i < l; ++i) {
        const file = files[i];
        const ext = path.extname(file);

        // ignore dot files
        if (file.indexOf(".") === 0) {
          continue;
        }

        // if json+html file isn't inside lookup, mark for deletion
        if (componentsLookup.indexOf(path.basename(file, ext)) === -1) {
          deleteQueue.push(file);
        }
      }
    }

    // remove file by passing shorter queue
    function removeFile(q) {
      if (!q.length) {
        process.send(true);
        return;
      }

      const file = q.shift();
      rimraf(path.resolve(paths.output, file), { read: false }, () => {
        removeFile(q);
      });
    }

    removeFile(deleteQueue);
  });
}
403915
def complete_file(self, text, line, begidx, endidx):
        """"""

        opts = self.FILE_OPTS

        if not text:
            completions = opts
        else:
            completions = [f
                           for f in opts
                           if f.startswith(text)
                           ]
        return completions
1354118
def abort(self):
        
        self._coll.chunks.delete_many(
            {"files_id": self._file['_id']}, session=self._session)
        self._coll.files.delete_one(
            {"_id": self._file['_id']}, session=self._session)
        object.__setattr__(self, "_closed", True)
398460
function walk(files, cb, list) {
    var i = 0;
    list = list || [];

    function check(file, cb) {
      fs.stat(file, function onStat(err, stats) {
        if(err) return cb(err);
        if(stats.isFile() && !/\.js$/.test(file)) {
          log.warning('ignoring %s', file);
          return cb();
        }
        if(stats.isFile()) {
          list.push(file);
          return cb(null, list);
        }else{
          return fs.readdir(file, function onRead(err, files) {
            if(err) return cb(err);
            if(!files.length) return cb();
            files = files.map(function(nm) {
              return path.join(file, nm);
            })
            //files.forEach()
            return walk(files, cb, list);
          })
        }
      });
    }

    check(files[i], function onCheck(err, list) {
      if(err) return cb(err);
      if(i === files.length - 1) {
        return cb(null, list);
      }
      i++;
      check(files[i], onCheck);
    });
  }
852828
def _complete_exit(self, cmd, args, text):
        """"""
        if args:
            return
        return [ x for x in { 'root', 'all', } \
                if x.startswith(text) ]
963053
def _closeResources(self):
        
        logger.info("Closing: {}".format(self._fileName))
        self._ncGroup.close()
        self._ncGroup = None
708601
def finish
      begin
        ::FileUtils.remove_entry_secure(tls[:tmpdir]) if tls[:tmpdir]
      rescue ::Exception => e
        @logger.note_warning(e.message)
      end
    ensure
      # Cleanup thread-local storage
      tls.clear
    end
445252
public void close() throws IOException {
    LOG.info(getTask()+" done; removing files.");
    getTask().getProgress().setStatus("closed");
    mapOutputFile.removeAll(getTask().getTaskID());
  }