note 116550 added to function.ftp-mkdir
| From: | PayamNaderi | Date: | Wed, 21 Jan 2015 09:06:40 +0000 |
| Subject: | note 116550 added to function.ftp-mkdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201487@lists.php.net to get a copy of this message | ||
Make Directories Recuresively:
<?php
// It's part of my Filesystem Abstraction For FTP Driver
// @see https://github.com/phPoirot/Filesystem
// the function contains some method that not included here
// but it's self revealing.
// hope help someone
function mkDir(iDirectoryInfo $dir, iPermissions $mode)
{
$dirpath = $dir->filePath()->toString();
if (in_array($dirpath, ['.', '/']))
return $this;
$cwdTmp = $this->getCwd(); // store current working dir
// Its may included '.' or '' for leading slashes /dir
$pathSections = (explode('/', $dirpath));
do {
$mkdir = array_shift($pathSections);
} while(in_array($mkdir, ['.']));
if (!$this->isDir($mkdir)) {
// create directory if not exists
if (ftp_mkdir($this->getConnect(), $mkdir) === false)
throw new \Exception(sprintf(
'Failed To Make Directory "%s".'
, $mkdir
), null, new \Exception(error_get_last()['message']));
$this->chmod(new Directory($mkdir), $mode);
}
$this->chDir(new Directory($mkdir));
$this->mkDir(
new Directory(implode('/', $pathSections))
, $mode
);
$this->chDir($cwdTmp); // get back to working directory
return $this;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 91.98.140.239
----
Manual Page -- http://php.net/manual/en/function.ftp-mkdir.php
Edit -- https://master.php.net/note/edit/116550
Del: integrated -- https://master.php.net/note/delete/116550/integrated
Del: useless -- https://master.php.net/note/delete/116550/useless
Del: bad code -- https://master.php.net/note/delete/116550/bad+code
Del: spam -- https://master.php.net/note/delete/116550/spam
Del: non-english -- https://master.php.net/note/delete/116550/non-english
Del: in docs -- https://master.php.net/note/delete/116550/in+docs
Del: other reasons-- https://master.php.net/note/delete/116550
Reject -- https://master.php.net/note/reject/116550
Search -- https://master.php.net/manage/user-notes.php