Ignore:
Timestamp:
2012/04/17 17:43:10 (14 years ago)
Author:
shutta
Message:

#1612 不要な関数の削除
SC_UtilsとSC_Helper_FileManager間の重複している(もしくは同機能の)関数の整理。

Location:
branches/version-2_12-dev/data/class/helper
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php

    r21686 r21757  
    248248            $res = true; 
    249249        } else { 
    250             $res = SC_Utils_Ex::sfReadFile($tmp_filename); 
     250            $res = SC_Helper_FileManager_Ex::sfReadFile($tmp_filename); 
    251251        } 
    252252 
  • branches/version-2_12-dev/data/class/helper/SC_Helper_FileManager.php

    r21755 r21757  
    121121 
    122122    /** 
    123      * 指定したディレクトリ又はファイルを削除する. 
    124      * 
    125      * @param string $dir 削除するディレクトリ又はファイル 
    126      * @return void 
    127      */ 
    128     function sfDeleteDir($dir) { 
    129         $arrResult = array(); 
    130         if (file_exists($dir)) { 
    131             // ディレクトリかチェック 
    132             if (is_dir($dir)) { 
    133                 if ($handle = opendir("$dir")) { 
    134                     $cnt = 0; 
    135                     while (false !== ($item = readdir($handle))) { 
    136                         if ($item != '.' && $item != '..') { 
    137                             if (is_dir("$dir/$item")) { 
    138                                 $this->sfDeleteDir("$dir/$item"); 
    139                             } else { 
    140                                 $arrResult[$cnt]['result'] = @unlink("$dir/$item"); 
    141                                 $arrResult[$cnt]['file_name'] = "$dir/$item"; 
    142                             } 
    143                         } 
    144                         $cnt++; 
    145                     } 
    146                 } 
    147                 closedir($handle); 
    148                 $arrResult[$cnt]['result'] = @rmdir($dir); 
    149                 $arrResult[$cnt]['file_name'] = "$dir/$item"; 
    150             } else { 
    151                 // ファイル削除 
    152                 $arrResult[0]['result'] = @unlink("$dir"); 
    153                 $arrResult[0]['file_name'] = "$dir"; 
    154             } 
    155         } 
    156  
    157         return $arrResult; 
    158     } 
    159  
    160     /** 
    161123     * ツリー生成用配列取得(javascriptに渡す用). 
    162124     * 
     
    373335        $debug_message = $dir . ' から ' . $dlFileName . " を作成します...\n"; 
    374336        // ファイル一覧取得 
    375         $arrFileHash = SC_Utils_Ex::sfGetFileList($dir); 
     337        $arrFileHash = SC_Helper_FileManager_Ex::sfGetFileList($dir); 
    376338        foreach ($arrFileHash as $val) { 
    377339            $arrFileList[] = $val['file_name']; 
     
    419381 
    420382        // フォルダ削除 
    421         SC_Utils_Ex::sfDelFile($dir . '/' . $unpacking_name); 
     383        SC_Helper_FileManager_Ex::deleteFile($dir . '/' . $unpacking_name); 
    422384        // 圧縮ファイル削除 
    423385        unlink($path); 
    424386        return $result; 
    425387    } 
     388 
     389    /** 
     390     * 指定されたパスの配下を再帰的に削除. 
     391     * 
     392     * @param string  $path       削除対象のディレクトリまたはファイルのパス 
     393     * @param boolean $del_myself $pathそのものを削除するか. true なら削除する. 
     394     * @return void 
     395     */ 
     396    function deleteFile($path, $del_myself = true) { 
     397        $flg = false; 
     398        // 対象が存在するかを検証. 
     399        if (file_exists($path) === false) { 
     400            GC_Utils_Ex::gfPrintLog($path . ' が存在しません.'); 
     401        } elseif (is_dir($path)) { 
     402            // ディレクトリが指定された場合 
     403            $handle = opendir($path); 
     404            if (!$handle) { 
     405                GC_Utils_Ex::gfPrintLog($path . ' が開けませんでした.'); 
     406            } 
     407            while (($item = readdir($handle)) !== false) { 
     408                if ($item === '.' || $item === '..') continue; 
     409                $cur_path = $path . '/' . $item; 
     410                if (is_dir($cur_path)) { 
     411                    // ディレクトリの場合、再帰処理 
     412                    $flg = SC_Helper_FileManager_Ex::deleteFile($cur_path); 
     413                } else { 
     414                    // ファイルの場合、unlink 
     415                    $flg = @unlink($cur_path); 
     416                } 
     417            } 
     418            closedir($handle); 
     419            // ディレクトリを削除 
     420            GC_Utils_Ex::gfPrintLog($path . ' を削除します.'); 
     421            if ($del_myself) { 
     422                $flg = @rmdir($path); 
     423            } 
     424        } else { 
     425            // ファイルが指定された場合. 
     426            GC_Utils_Ex::gfPrintLog($path . ' を削除します.'); 
     427            $flg = @unlink($path); 
     428        } 
     429        return $flg; 
     430    } 
    426431} 
Note: See TracChangeset for help on using the changeset viewer.