Exemplo n.º 1
0
Arquivo: Dir.php Projeto: mbcraft/piol
 /**
  * 
  * Creates a new subdirectory inside this one, or returns an existing one, 
  * returning a \Mbcraft\Piol\Dir instance pointing to it.
  * 
  * @param string $name The name of the subdirectory to create.
  * @return \Mbcraft\Piol\Dir The existing subdirectory.
  * @throws \Mbcraft\Piol\IOException If the specified name is already used for another kind of file system element or it's not possible to create the directory.
  * 
  * @api
  */
 public function newSubdir($name)
 {
     FileSystemUtils::checkValidFilename($name);
     if (FileSystemUtils::isDir($this->__path . DS . $name)) {
         //directory already exists
         //echo "Directory already exists : ".$this->__full_path."/".$name;
         return new Dir($this->__path . DS . $name);
     }
     if (FileSystemUtils::isFile($this->__path . DS . $name)) {
         throw new IOException("The specified name is an already existing file");
     }
     //directory or files do not exists
     $result = @mkdir($this->__full_path . $name, __FileSystemElement::getDefaultPermissionsOctal(), true);
     if ($result == true) {
         return new Dir($this->__path . $name);
     } else {
         throw new IOException("Unable to create dir : " . $this->__full_path . $name);
     }
 }