Example #1
0
 /**
  * Create a new database.
  *
  * @param boolean $quoted
  *   Quote the database name. Mysql uses backticks to quote which can cause problems
  *   in a Windows shell. Set TRUE if the CREATE is not running on the bash command line.
  */
 public function createdb($quoted = FALSE)
 {
     $file = $this->db_spec['database'];
     if (file_exists($file)) {
         drush_log("SQLITE: Deleting existing database '{$file}'", 'debug');
         drush_delete_dir($file, TRUE);
     }
     // Make sure sqlite can create file
     $path = dirname($file);
     drush_log("SQLITE: creating '{$path}' for creating '{$file}'", 'debug');
     drush_mkdir($path);
     if (!file_exists($path)) {
         drush_log("SQLITE: Cannot create {$path}", 'error');
     }
 }
Example #2
0
 /**
  * Create a new database.
  *
  * @param boolean $quoted
  *   Quote the database name. Mysql uses backticks to quote which can cause problems
  *   in a Windows shell. Set TRUE if the CREATE is not running on the bash command line.
  */
 public function createdb($quoted = FALSE)
 {
     $file = $this->db_spec['database'];
     if (file_exists($file)) {
         drush_log("SQLITE: Deleting existing database '{$file}'", LogLevel::DEBUG);
         drush_delete_dir($file, TRUE);
     }
     // Make sure sqlite can create file
     $path = dirname($file);
     drush_log("SQLITE: creating '{$path}' for creating '{$file}'", LogLevel::DEBUG);
     drush_mkdir($path);
     if (!file_exists($path)) {
         drush_log("SQLITE: Cannot create {$path}", LogLevel::ERROR);
         return FALSE;
     } else {
         return TRUE;
     }
 }
Example #3
0
 public function removeFile($file)
 {
     $success = FALSE;
     if (is_link($file)) {
         $success = unlink($file);
     } else {
         if (is_dir($file)) {
             $succes = drush_delete_dir($file);
         } else {
             if (is_file($file)) {
                 $success = unlink($file);
             }
         }
     }
     if ($success) {
         drush_log(dt('Removed @file', array('@file' => $file)), 'success');
     } else {
         // @throw file could not be removed
     }
 }
Example #4
0
 function clear($cid = NULL, $wildcard = FALSE)
 {
     $bin_dir = $this->cacheDirectory();
     $files = array();
     if (empty($cid)) {
         drush_delete_dir($bin_dir, TRUE);
     } else {
         if ($wildcard) {
             if ($cid == '*') {
                 drush_delete_dir($bin_dir, TRUE);
             } else {
                 $matches = drush_scan_directory($bin_dir, "/^{$cid}/", array('.', '..'));
                 $files = $files + array_keys($matches);
             }
         } else {
             $files[] = $this->getFilePath($cid);
         }
         foreach ($files as $f) {
             // Delete immediately instead of drush_register_file_for_deletion().
             unlink($f);
         }
     }
 }