/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/FileDirectory.php (6485B)
setMode($mode);
parent::__construct($streamName, $context, $wait);
return;
}
/**
* Open the stream and return the associated resource.
*/
protected function &_open(string $streamName, StreamContext $context = null)
{
if (false === \is_dir($streamName)) {
if ($this->getMode() === self::MODE_READ) {
throw new FileDoesNotExistException('Directory %s does not exist.', 0, $streamName);
} else {
self::create(
$streamName,
$this->getMode(),
null !== $context
? $context->getContext()
: null
);
}
}
$out = null;
return $out;
}
/**
* Close the current stream.
*/
protected function _close(): bool
{
return true;
}
/**
* Recursive copy of a directory.
*/
public function copy(string $to, bool $force = StreamTouchable::DO_NOT_OVERWRITE): bool
{
if (empty($to)) {
throw new FileException('The destination path (to copy) is empty.', 1);
}
$from = $this->getStreamName();
$fromLength = \strlen($from) + 1;
$finder = new FileFinder();
$finder->in($from);
self::create($to, self::MODE_CREATE_RECURSIVE);
foreach ($finder as $file) {
$relative = \substr($file->getPathname(), $fromLength);
$_to = $to.\DIRECTORY_SEPARATOR.$relative;
if (true === $file->isDir()) {
self::create($_to, self::MODE_CREATE);
continue;
}
// This is not possible to do `$file->open()->copy();
// $file->close();` because the file will be opened in read and
// write mode. In a PHAR for instance, this operation is
// forbidden. So a special care must be taken to open file in read
// only mode.
$handle = null;
if (true === $file->isFile()) {
$handle = new FileRead($file->getPathname());
} elseif (true === $file->isDir()) {
$handle = new self($file->getPathName());
} elseif (true === $file->isLink()) {
$handle = new FileLinkRead($file->getPathName());
}
if (null !== $handle) {
$handle->copy($_to, $force);
$handle->close();
}
}
return true;
}
/**
* Delete a directory.
*/
public function delete(): bool
{
$from = $this->getStreamName();
$finder = new FileFinder();
$finder->in($from)
->childFirst();
foreach ($finder as $file) {
$file->open()->delete();
$file->close();
}
if (null === $this->getStreamContext()) {
return @\rmdir($from);
}
return @\rmdir($from, $this->getStreamContext()->getContext());
}
/**
* Create a directory.
*/
public static function create(
string $name,
string $mode = self::MODE_CREATE_RECURSIVE,
string $context = null
): bool {
if (true === \is_dir($name)) {
return true;
}
if (empty($name)) {
return false;
}
if (null !== $context) {
if (false === StreamContext::contextExists($context)) {
throw new FileException('Context %s was not previously declared, cannot retrieve '.'this context.', 2, $context);
} else {
$context = StreamContext::getInstance($context);
}
}
if (null === $context) {
return @\mkdir(
$name,
0755,
self::MODE_CREATE_RECURSIVE === $mode
);
}
return @\mkdir(
$name,
0755,
self::MODE_CREATE_RECURSIVE === $mode,
$context->getContext()
);
}
}