Ignore:
Timestamp:
2007/10/14 22:55:13 (19 years ago)
Author:
adachi
Message:

オーナーズストア連携暫定コミット

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/batch/SC_Batch_Update.php

    r16343 r16420  
    3737     */ 
    3838    function execute($target = ".") { 
     39        $arrLog = array(); 
    3940        $includeArray = explode(',', $this->includes); 
    4041        $excludeArray = explode(',', $this->excludes); 
     
    5556                // distinfo.php を読み込む 
    5657                if ($fileName == "distinfo.php") { 
    57                     include_once($fileName); 
     58                    include_once($path); 
    5859                } 
    5960 
    6061                // 除外ファイルをスキップ 
    6162                if (in_array($fileName, $excludeArray)) { 
    62                     echo "excludes by " . $path . "\n"; 
     63                    $arrLog[] = "excludes by " . $path . "\n"; 
    6364                    continue; 
    6465                } 
     
    6768                $sha1 = sha1_file($path); 
    6869 
    69                 echo $sha1 . " => " . $path . "\n"; 
     70                $arrLog[] = $sha1 . " => " . $path . "\n"; 
    7071 
    7172 
     
    8182                            $out = $distinfo[$sha1]; 
    8283                        } else { 
    83                             die("ハッシュ値が一致しないため, コピー先が取得できません."); 
     84                            $arrLog[] = "ハッシュ値が一致しないため, コピー先が取得できません."; 
     85                            die(); 
    8486                        } 
    8587 
    8688                        // ファイルを書き出しモードで開く 
    87                         $handle = fopen($out, "w"); 
     89                        $handle = @fopen($out, "w"); 
    8890                        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                            } 
    9198                        } 
    9299 
    93100                        // 取得した内容を書き込む 
    94101                        if (fwrite($handle, $contents) === false) { 
    95                             echo "Cannot write to file (" . $out . ")"; 
     102                            $arrLog[] = "Cannot write to file (" . $out . ")\n"; 
    96103                            continue; 
    97104                        } 
    98105 
    99                         echo "copyed " . $out . "\n"; 
     106                        $arrLog[] = "copyed " . $out . "\n"; 
    100107                        // ファイルを閉じる 
    101108                        fclose($handle); 
     
    104111            } 
    105112        } 
    106         echo "Finished Successful!\n"; 
     113        $arrLog[] = "Finished Successful!\n"; 
     114        return $arrLog; 
    107115    } 
    108116 
     
    123131        return $alldirs; 
    124132    } 
     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} 
    125153} 
    126154?> 
Note: See TracChangeset for help on using the changeset viewer.