/var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/Readline/Hoa
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/psy/psysh/src/Readline/Hoa/File.php (7853B)
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 FileException('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;
}
/**
* Open the stream and return the associated resource.
*/
protected function &_open(string $streamName, StreamContext $context = null)
{
if (\substr($streamName, 0, 4) === 'file' &&
false === \is_dir(\dirname($streamName))) {
throw new FileException('Directory %s does not exist. Could not open file %s.', 1, [\dirname($streamName), \basename($streamName)]);
}
if (null === $context) {
if (false === $out = @\fopen($streamName, $this->getMode(), true)) {
throw new FileException('Failed to open stream %s.', 2, $streamName);
}
return $out;
}
$out = @\fopen(
$streamName,
$this->getMode(),
true,
$context->getContext()
);
if (false === $out) {
throw new FileException('Failed to open stream %s.', 3, $streamName);
}
return $out;
}
/**
* Close the current stream.
*/
protected function _close(): bool
{
return @\fclose($this->getStream());
}
/**
* Start a new buffer.
* The callable acts like a light filter.
*/
public function newBuffer($callable = null, int $size = null): int
{
$this->setStreamBuffer($size);
// @TODO manage $callable as a filter?
return 1;
}
/**
* Flush the output to a stream.
*/
public function flush(): bool
{
return \fflush($this->getStream());
}
/**
* Delete buffer.
*/
public function deleteBuffer(): bool
{
return $this->disableStreamBuffer();
}
/**
* Get bufffer level.
*/
public function getBufferLevel(): int
{
return 1;
}
/**
* Get buffer size.
*/
public function getBufferSize(): int
{
return $this->getStreamBufferSize();
}
/**
* Portable advisory locking.
*/
public function lock(int $operation): bool
{
return \flock($this->getStream(), $operation);
}
/**
* Rewind the position of a stream pointer.
*/
public function rewind(): bool
{
return \rewind($this->getStream());
}
/**
* Seek on a stream pointer.
*/
public function seek(int $offset, int $whence = StreamPointable::SEEK_SET): int
{
return \fseek($this->getStream(), $offset, $whence);
}
/**
* Get the current position of the stream pointer.
*/
public function tell(): int
{
$stream = $this->getStream();
if (null === $stream) {
return 0;
}
return \ftell($stream);
}
/**
* Create a file.
*/
public static function create(string $name)
{
if (\file_exists($name)) {
return true;
}
return \touch($name);
}
}