Example #1
0
 /**
  * Remove a directory even if it is not empty.
  */
 public static function removeDirectory($remove_path)
 {
     if (!file_exists($remove_path)) {
         return;
     }
     if (($path = realpath($remove_path)) !== FALSE) {
         if (@chmod($path, 0777) === FALSE) {
             throw new Exception(T_("Can't delete directory %s. Permission denied."), $path);
         }
         try {
             if (is_dir($path)) {
                 $dh = opendir($path);
             } else {
                 return;
             }
         } catch (Exception $e) {
             return;
         }
         while (($file = readdir($dh)) !== false) {
             if ($file != '.' && $file != '..') {
                 if (is_dir($path . DIRECTORY_SEPARATOR . $file)) {
                     DirectoryUtils::removeDirectory($path . DIRECTORY_SEPARATOR . $file);
                 } else {
                     if (chmod($path . DIRECTORY_SEPARATOR . $file, 0777) === FALSE) {
                         throw new USVN_Exception(T_("Can't delete file %s.", $path . DIRECTORY_SEPARATOR . $file));
                     }
                     unlink($path . DIRECTORY_SEPARATOR . $file);
                 }
             }
         }
         closedir($dh);
         if (@rmdir($path) === FALSE) {
             throw new Exception(T_("Can't delete directory %s."), $path);
         }
     }
 }
Example #2
0
 /**
  * Create standard svn directories
  * /trunk
  * /tags
  * /branches
  *
  * @param string Path to create subversion
  */
 public static function createStandardDirectories($path)
 {
     $tmpdir = DirectoryUtils::getTmpDirectory();
     try {
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "trunk");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "branches");
         mkdir($tmpdir . DIRECTORY_SEPARATOR . "tags");
         SVNUtils::_svnImport($path, $tmpdir);
     } catch (Exception $e) {
         DirectoryUtils::removeDirectory($path);
         DirectoryUtils::removeDirectory($tmpdir);
         throw $e;
     }
     DirectoryUtils::removeDirectory($tmpdir);
 }