Opens the given regular file with the given options, truncating it if necessary and
incrementing its open count. Returns the given file.
165720
private static RegularFile open(RegularFile file, Set<OpenOption> options) {
    if (options.contains(TRUNCATE_EXISTING) && options.contains(WRITE)) {
      file.writeLock().lock();
      try {
        file.truncate(0);
      } finally {
        file.writeLock().unlock();
      }
    }

    // must be opened while holding a file store lock to ensure no race between opening and
    // deleting the file
    file.opened();

    return file;
  }
1020500
def open(self, mode='rb'):
        
        file = self.storage.open(self.relative_name, mode=mode)  # type: File
        return file
564344
def _open(self):
        
        if self.fileName.endswith(".gz"):
            return gzip.open(self.fileName)
        elif self.fileName.endswith(".bz2"):
            return bz2.BZ2File(self.fileName)
        else:
            return open(self.fileName)
16299
def Open(self, file_object):
    
    file_object.seek(0, os.SEEK_SET)
    signature_data = file_object.read(6)

    self.file_format = None
    if len(signature_data) > 2:
      if signature_data[:2] == self._CPIO_SIGNATURE_BINARY_BIG_ENDIAN:
        self.file_format = 'bin-big-endian'
      elif signature_data[:2] == self._CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN:
        self.file_format = 'bin-little-endian'
      elif signature_data == self._CPIO_SIGNATURE_PORTABLE_ASCII:
        self.file_format = 'odc'
      elif signature_data == self._CPIO_SIGNATURE_NEW_ASCII:
        self.file_format = 'newc'
      elif signature_data == self._CPIO_SIGNATURE_NEW_ASCII_WITH_CHECKSUM:
        self.file_format = 'crc'

    if self.file_format is None:
      raise IOError('Unsupported CPIO format.')

    self._file_object = file_object
    self._file_size = file_object.get_size()

    self._ReadFileEntries(self._file_object)
924903
def _open(filename, mode='r', buffering=0):
    """"""
    if mode not in ('r', 'rb', 'rU'):
        raise RuntimeError("Invalid open file mode, must be 'r', 'rb', or 'rU'")
    if buffering > MAX_OPEN_BUFFER:
        raise RuntimeError("Invalid buffering value, max buffer size is {}".format(MAX_OPEN_BUFFER))
    return open(filename, mode, buffering)
524457
def _open_file_obj(f, mode="r"):
    
    if isinstance(f, six.string_types):
        if f.startswith(("http://", "https://")):
            file_obj = _urlopen(f)
            yield file_obj
            file_obj.close()
        else:
            with open(f, mode) as file_obj:
                yield file_obj
    else:
        yield f
552849
public FSDataInputStream open(Path f, ReadOptions options) throws IOException {
    return open(f, getDefaultBufferSize(), options);
  }
795412
def Open(self, file_object):
    
    self._file_object = file_object
    self._regf_file.open_file_object(self._file_object)
    return True
845327
def _open_file(self, mode, encoding=None):
        
        if self._filename[-4:] == '.bz2':
            self._file = bz2.open(self._filename, mode=mode, encoding=encoding)
        else:
            self._file = open(self._filename, mode=mode, encoding=encoding)
1096995
def taropen(cls, name, mode="r", fileobj=None, **kwargs):
        
        if len(mode) > 1 or mode not in "raw":
            raise ValueError("mode must be 'r', 'a' or 'w'")
        return cls(name, mode, fileobj, **kwargs)
196381
def open_file(filename, mode='rb'):
    
    if (('r' not in mode or hasattr(filename, 'read')) and
        (('a' not in mode and 'w' not in mode) or hasattr(filename, 'write')) and
        hasattr(filename, '__iter__')):
        return filename
    elif isinstance(filename, string_type):
        if filename == '-' and 'r' in mode:
            if PY3:
                return sys.stdin.buffer
            return sys.stdin
        elif filename == '-' and ('w' in mode or 'a' in mode):
            if PY3:
                return sys.stdout.buffer
            return sys.stdout
        if filename.lower().count('.zip:'):
            assert 'r' in mode
            assert filename.count(':') == 1
            import zipfile
            zipped_file = zipfile.ZipFile(filename.split(':')[0])
            unzipped_file = zipped_file.open(filename.split(':')[1], 'r')
            zipped_file.close()
            return unzipped_file
        elif filename.lower().endswith('.gz'):
            import gzip
            return gzip.open(filename, mode)
        elif filename.lower().endswith('.xz'):
            import lzma
            tmp = lzma.LZMAFile(filename, mode)
            dir(tmp)
            return tmp
        else:
            return open(filename, mode)
    else:
        raise Exception('Unknown type for argument filename')
546375
def open(filename, mode="rb", format = None):
    
    if format == "auto" or format == None:
        format = detect_format(filename)

    if format == "warc":
        return WARCFile(filename, mode)
    elif format == "arc":
        return ARCFile(filename, mode)
    else:
        raise IOError("Don't know how to open '%s' files"%format)
630138
function openFile(filename) {
  return new Promise((resolve, reject) => {
    opener(filename, null, err => err === null ? resolve(filename) : reject(err));
  });
}
501116
def get_open_file(self, file_des):
        
        if not is_int_type(file_des):
            raise TypeError('an integer is required')
        if (file_des >= len(self.open_files) or
                self.open_files[file_des] is None):
            self.raise_os_error(errno.EBADF, str(file_des))
        return self.open_files[file_des][0]
1224690
def get_file(self, file_path, mode="r"):
        
        return open(self.cont_path(file_path), mode=mode)
1289879
def smart_open(filename: str, mode: str = 'Ur', buffering: int = -1,
               encoding: str = None, errors: str = None, newline: str = None,
               closefd: bool = True) -> IO:
    
    # https://stackoverflow.com/questions/17602878/how-to-handle-both-with-open-and-sys-stdout-nicely  # noqa
    # https://stackoverflow.com/questions/1744989/read-from-file-or-stdin/29824059#29824059  # noqa
    if filename == '-':
        if mode is None or mode == '' or 'r' in mode:
            fh = sys.stdin
        else:
            fh = sys.stdout
    else:
        fh = open(filename, mode=mode,
                  buffering=buffering, encoding=encoding, errors=errors,
                  newline=newline, closefd=closefd)
    try:
        yield fh
    finally:
        if filename is not '-':
            fh.close()
307691
def _open(self, path, skip_to_end = True, offset = None):
      """"""
      fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK))

      # If the file is being opened for the first time, jump to the end.
      # Otherwise, it is being reopened after a rotation, and we want
      # content from the beginning.
      if offset is None:
         if skip_to_end:
            fh.seek(0, 2)

            self._offset = fh.tell()
         else:
            self._offset = 0
      else:
         fh.seek(offset)
         self._offset = fh.tell()
      
      self._fh = fh
      self._lastsize = fh.tell()
      self._inode = os.stat(self._path).st_ino