示例#1
0
 /**
  * Close the opened stream.
  *
  * @return  mixed
  */
 public function close()
 {
     if (null === $this->_stream) {
         return;
     }
     return $this->_stream->close();
 }
示例#2
0
文件: File.php 项目: Grummfy/Central
 /**
  * Open a file.
  *
  * @param   string  $streamName    Stream name (or file descriptor).
  * @param   string  $mode          Open mode, see the self::MODE_*
  *                                 constants.
  * @param   string  $context       Context ID (please, see the
  *                                 \Hoa\Stream\Context class).
  * @param   bool    $wait          Differ opening or not.
  * @return  void
  * @throws  \Hoa\File\Exception
  */
 public function __construct($streamName, $mode, $context = null, $wait = false)
 {
     $this->setMode($mode);
     switch ($streamName) {
         case '0':
             $streamName = 'php://stdin';
             break;
         case '1':
             $streamName = 'php://stdout';
             break;
         case '2':
             $streamName = 'php://stderr';
             break;
         default:
             if (true === ctype_digit($streamName)) {
                 if (PHP_VERSION_ID >= 50306) {
                     $streamName = 'php://fd/' . $streamName;
                 } else {
                     throw new Exception('You need PHP5.3.6 to use a file descriptor ' . 'other than 0, 1 or 2 (tried %d with PHP%s).', 0, [$streamName, PHP_VERSION]);
                 }
             }
     }
     parent::__construct($streamName, $context, $wait);
     return;
 }
示例#3
0
 /**
  * Open a directory.
  *
  * @param   string  $streamName    Stream name.
  * @param   string  $mode          Open mode, see the self::MODE* constants.
  * @param   string  $context       Context ID (please, see the
  *                                 \Hoa\Stream\Context class).
  * @param   bool    $wait          Differ opening or not.
  * @return  void
  */
 public function __construct($streamName, $mode = self::MODE_READ, $context = null, $wait = false)
 {
     $this->setMode($mode);
     parent::__construct($streamName, $context, $wait);
     return;
 }