Changeset 16420 for branches/feature-module-update/data/class/batch
- Timestamp:
- 2007/10/14 22:55:13 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/data/class/batch/SC_Batch_Update.php
r16343 r16420 37 37 */ 38 38 function execute($target = ".") { 39 $arrLog = array(); 39 40 $includeArray = explode(',', $this->includes); 40 41 $excludeArray = explode(',', $this->excludes); … … 55 56 // distinfo.php を読み込む 56 57 if ($fileName == "distinfo.php") { 57 include_once($ fileName);58 include_once($path); 58 59 } 59 60 60 61 // 除外ファイルをスキップ 61 62 if (in_array($fileName, $excludeArray)) { 62 echo"excludes by " . $path . "\n";63 $arrLog[] = "excludes by " . $path . "\n"; 63 64 continue; 64 65 } … … 67 68 $sha1 = sha1_file($path); 68 69 69 echo$sha1 . " => " . $path . "\n";70 $arrLog[] = $sha1 . " => " . $path . "\n"; 70 71 71 72 … … 81 82 $out = $distinfo[$sha1]; 82 83 } else { 83 die("ハッシュ値が一致しないため, コピー先が取得できません."); 84 $arrLog[] = "ハッシュ値が一致しないため, コピー先が取得できません."; 85 die(); 84 86 } 85 87 86 88 // ファイルを書き出しモードで開く 87 $handle = fopen($out, "w");89 $handle = @fopen($out, "w"); 88 90 if (!$handle) { 89 echo "Cannot open file (". $out . ")"; 90 continue; 91 // ディレクトリ作成を行ってリトライ 92 $this->mkdir_p($out); 93 $handle = @fopen($out, "w"); 94 if (!$handle) { 95 $arrLog[] = "Cannot open file (". $out . ")\n"; 96 continue; 97 } 91 98 } 92 99 93 100 // 取得した内容を書き込む 94 101 if (fwrite($handle, $contents) === false) { 95 echo "Cannot write to file (" . $out . ")";102 $arrLog[] = "Cannot write to file (" . $out . ")\n"; 96 103 continue; 97 104 } 98 105 99 echo"copyed " . $out . "\n";106 $arrLog[] = "copyed " . $out . "\n"; 100 107 // ファイルを閉じる 101 108 fclose($handle); … … 104 111 } 105 112 } 106 echo "Finished Successful!\n"; 113 $arrLog[] = "Finished Successful!\n"; 114 return $arrLog; 107 115 } 108 116 … … 123 131 return $alldirs; 124 132 } 133 134 /** 135 * mkdir -p 136 * 137 * @param string $path 絶対パス 138 */ 139 function mkdir_p($path){ 140 $path = dirname($path); 141 $path = str_replace ('\\', '/', $path); 142 143 $arrDirs = explode("/", $path); 144 $dir = ''; 145 146 foreach($arrDirs as $n){ 147 $dir .= $n . '/'; 148 if(!file_exists($dir)) { 149 if (!@mkdir($dir)) return; 150 } 151 } 152 } 125 153 } 126 154 ?>
Note: See TracChangeset
for help on using the changeset viewer.
