public function createDir($dir)
{
if (trim($dir, '/') === '' || $this->isDir($dir)) {
return;
}
$parts = explode('/', $dir);
$path = '';
while (!empty($parts)) {
$path .= array_shift($parts);
try {
if ($path !== '') {
$this->ftp('mkdir', $path);
}
} catch (FtpException $e) {
if (!$this->isDir($path)) {
throw new FtpException("Cannot create directory '{$path}'.");
}
}
$path .= '/';
}
}