Opens a file for writing or reading.
511986
def open(self, directory=None, filename=None, mode="rb"):
        """"""
        path = os.path.join(directory, filename)
        return open(path, mode)
1307772
def open_file(self) :
        """"""
        if self.isdir() : raise Exception("FSQuery tried to open a directory as a file : %s" % self.abs)
        return open(self.abs)
766060
private function open()
    {
        if (null === ($this->handle = fopen($this->file, 'rb'))) {
            $this->handle = null;

            throw new RuntimeException(
                sprintf(
                    'The file "%s" could not be opened for reading.',
                    $this->file
                )
            );
        }
    }
1192714
def try_opening_file(self):
        ''''''
        if os.path.isfile(self.path):
            self.file = open(self.path, 'r')
            self.file_is_opened = True
304375
def open_file(path):
    """"""
    if sys.platform=='win32':
        os.startfile(path)
        #subprocess.Popen(['start', path], shell= True)
    
    elif sys.platform=='darwin':
        subprocess.Popen(['open', path])
    
    else:
        try:
            subprocess.Popen(['xdg-open', path])
        except OSError:
            pass
106145
def _readfile(self, filename):
        
        f = open(filename)
        self.content = f.readlines()
        f.close()
41392
private synchronized void openFile()
  {
    try
    {
      String fName = _directory.getAbsolutePath()
                     + File.separatorChar + StreamLoader.FILE_PREFIX
                     + _stamp + _fileCount;
      if (_loader._compressDataBeforePut)
      {
        fName += StreamLoader.FILE_SUFFIX;
      }
      LOGGER.debug("openFile: {}", fName);

      OutputStream fileStream = new FileOutputStream(fName);
      if (_loader._compressDataBeforePut)
      {
        OutputStream gzipOutputStream = new GZIPOutputStream(
            fileStream, 64 * 1024, true)
        {
          {
            def.setLevel((int) _loader._compressLevel);
          }
        };
        _outstream = new BufferedOutputStream(gzipOutputStream);
      }
      else
      {
        _outstream = new BufferedOutputStream(fileStream);
      }

      _file = new File(fName);

      _fileCount++;
    }
    catch (IOException ex)
    {
      _loader.abort(new Loader.ConnectionError(Utils.getCause(ex)));
    }
  }
1207310
def open_for_write(path)
      dir = Pathname.new(path).dirname
      FileUtils.mkdir_p(dir) unless File.exist?(dir)
      File.open(path, 'w') do |f|
        yield f
      end
    end
673747
def read_file(*path):
    """"""
    real_path = os.path.realpath(os.path.join(*path))
    with click.open_file(real_path, "r") as fp:
        return fp.read()
801676
def writefile(openedfile, newcontents):
    """"""
    openedfile.seek(0)
    openedfile.truncate()
    openedfile.write(newcontents)
631477
def open(self, encoding=None):
        """"""
        try:
            if IS_GZIPPED_FILE.search(self._filename):
                _file = gzip.open(self._filename, 'rb')
            else:
                if encoding:
                    _file = io.open(self._filename, 'r', encoding=encoding, errors='replace')
                elif self._encoding:
                    _file = io.open(self._filename, 'r', encoding=self._encoding, errors='replace')
                else:
                    _file = io.open(self._filename, 'r', errors='replace')
        except IOError, e:
            self._log_warning(str(e))
            _file = None
            self.close()

        return _file
191093
def Open(self):
    
    if self._storage_file:
      raise IOError('Storage writer already opened.')

    self._storage_file = self._CreateStorageFile()

    if self._serializers_profiler:
      self._storage_file.SetSerializersProfiler(self._serializers_profiler)

    if self._storage_profiler:
      self._storage_file.SetStorageProfiler(self._storage_profiler)

    self._storage_file.Open(path=self._output_file, read_only=False)

    self._first_written_event_source_index = (
        self._storage_file.GetNumberOfEventSources())
    self._written_event_source_index = self._first_written_event_source_index
439677
static void open(File dir, String fileName) {
        if (dir.mkdirs() || dir.isDirectory()) {
            File file = new File(dir, fileName);
            try {
                out = new PrintStream(TextFileOutputStreamFactory.createOutputStream(file), true, "UTF-8");
                openedFile = file;
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
1009494
def opened(filename, mode):
    ""
    if isinstance(filename, str):
        file = open(filename, mode)
        try: 
            yield file
        finally: 
            if not file.closed:
                file.close()
    else:
        yield filename
6112
def open_file(file, mode):
	
	if hasattr(file, "read"):
		return file
	if hasattr(file, "open"):
		return file.open(mode)
	return open(file, mode)
837310
protected void openChannel(boolean readHeader) throws FileLockException, IOException {
        logger.debug("[OFile.openChannel] Opening channel for file: " + osFile);
        accessFile = new RandomAccessFile(osFile, (mode == AccessMode.READ_ONLY) ? "r" : "rw");
        accessFile.seek(0);
        channel = accessFile.getChannel();
        lock();
        if (mode == AccessMode.READ_ONLY) {
            headerBuffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, HEADER_SIZE);
        } else {
            headerBuffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, HEADER_SIZE);
        }
        if (readHeader) {
            readHeader();
        }
    }
968535
protected function openWriter()
    {
        $tempFolder = ($this->tempFolder) ? : sys_get_temp_dir();
        $this->book = new Workbook($tempFolder, $this->shouldCreateNewSheetsAutomatically, $this->defaultRowStyle);
        $this->book->addNewSheetAndMakeItCurrent();
    }