protected function openFileObject($mode, $skipEmptyLines)
    {
        if (!$this->getParent()->isDir()) {
            $this->getParent()->mkdirs();
        }

        $newFile = false;
        if (!$this->isFile()) {
            switch ($mode)
            {
                case 'w':
                case 'w+':
                case 'a':
                case 'a+':
                case 'x':
                case 'x+':
                    $newFile = true;
                    break;
            }
        }

        $this->fileObject = $this->openFile($mode);

        if ($skipEmptyLines) {
            $this->skipEmptyLines = true;
            $this->fileObject->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD| \SplFileObject::SKIP_EMPTY);
        } else {
            $this->fileObject->setFlags(\SplFileObject::DROP_NEW_LINE);
        }

        if ($newFile) {
            $this->chmod($this->defaul_permission);
        }
    }
protected function openFileObject($mode, $skipEmptyLines)
    {
        if (!$this->getParent()->isDir()) {
            $this->getParent()->mkdirs();
        }

        $newFile = false;
        if (!$this->isFile()) {
            switch ($mode)
            {
                case 'w':
                case 'w+':
                case 'a':
                case 'a+':
                case 'x':
                case 'x+':
                    $newFile = true;
                    break;
            }
        }

        $this->fileObject = $this->openFile($mode);

        if ($skipEmptyLines) {
            $this->skipEmptyLines = true;
            $this->fileObject->setFlags(\SplFileObject::DROP_NEW_LINE | \SplFileObject::READ_AHEAD| \SplFileObject::SKIP_EMPTY);
        } else {
            $this->fileObject->setFlags(\SplFileObject::DROP_NEW_LINE);
        }

        if ($newFile) {
            $this->chmod($this->defaul_permission);
        }
    }
protected function openFileObject ( $ mode , $ skipEmptyLines ) { if ( ! $ this -> getParent ( ) -> isDir ( ) ) { $ this -> getParent ( ) -> mkdirs ( ) ; } $ newFile = false ; if ( ! $ this -> isFile ( ) ) { switch ( $ mode ) { case 'w' : case 'w+' : case 'a' : case 'a+' : case 'x' : case 'x+' : $ newFile = true ; break ; } } $ this -> fileObject = $ this -> openFile ( $ mode ) ; if ( $ skipEmptyLines ) { $ this -> skipEmptyLines = true ; $ this -> fileObject -> setFlags ( \ SplFileObject :: DROP_NEW_LINE | \ SplFileObject :: READ_AHEAD | \ SplFileObject :: SKIP_EMPTY ) ; } else { $ this -> fileObject -> setFlags ( \ SplFileObject :: DROP_NEW_LINE ) ; } if ( $ newFile ) { $ this -> chmod ( $ this -> defaul_permission ) ; } }
file mode
r     = read only, beginning of file
r+    = read and write, beginning of file
w     = write only, beginning of file, empty file, create file if necessary
w+    = read and write, beginning of file, empty file, create file if nesessary
a     = write only, end of file, create file if necessary
a+    = read and write, end of file, create file if necessary
x     = write only, beginning of file, only create file
x+    = read and write, beginning of file, only create file

+----+----+-----+-----+---+------+
|mode|read|write|start|end|create|
+----+----+-----+-----+---+------+
| r  | x  |     |  x  |   |      |
+----+----+-----+-----+---+------+
| r+ | x  |  x  |  x  |   |      |
+----+----+-----+-----+---+------+
| w  |    |  x  |  x  |   |  opt |
+----+----+-----+-----+---+------+
| w+ | x  |  x  |  x  |   |  opt |
+----+----+-----+-----+---+------+
| a  |    |  x  |     | x |  opt |
+----+----+-----+-----+---+------+
| a+ | x  |  x  |     | x |  opt |
+----+----+-----+-----+---+------+
| x  |    |  x  |  x  |   | only |
+----+----+-----+-----+---+------+
| x+ | x  |  x  |  x  |   | only |
+----+----+-----+-----+---+------+

@param       string $mode file mode
@param       bool $skipEmptyLines true = skip empty lines, false = contains empty lines
@throws Exception\FileException
file mode r = read only beginning of file r + = read and write beginning of file w = write only beginning of file empty file create file if necessary w + = read and write beginning of file empty file create file if nesessary a = write only end of file create file if necessary a + = read and write end of file create file if necessary x = write only beginning of file only create file x + = read and write beginning of file only create file