Changeset 21757 for branches/version-2_12-dev/data/class/helper
- Timestamp:
- 2012/04/17 17:43:10 (14 years ago)
- Location:
- branches/version-2_12-dev/data/class/helper
- Files:
-
- 2 edited
-
SC_Helper_CSV.php (modified) (1 diff)
-
SC_Helper_FileManager.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php
r21686 r21757 248 248 $res = true; 249 249 } else { 250 $res = SC_ Utils_Ex::sfReadFile($tmp_filename);250 $res = SC_Helper_FileManager_Ex::sfReadFile($tmp_filename); 251 251 } 252 252 -
branches/version-2_12-dev/data/class/helper/SC_Helper_FileManager.php
r21755 r21757 121 121 122 122 /** 123 * 指定したディレクトリ又はファイルを削除する.124 *125 * @param string $dir 削除するディレクトリ又はファイル126 * @return void127 */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 /**161 123 * ツリー生成用配列取得(javascriptに渡す用). 162 124 * … … 373 335 $debug_message = $dir . ' から ' . $dlFileName . " を作成します...\n"; 374 336 // ファイル一覧取得 375 $arrFileHash = SC_ Utils_Ex::sfGetFileList($dir);337 $arrFileHash = SC_Helper_FileManager_Ex::sfGetFileList($dir); 376 338 foreach ($arrFileHash as $val) { 377 339 $arrFileList[] = $val['file_name']; … … 419 381 420 382 // フォルダ削除 421 SC_ Utils_Ex::sfDelFile($dir . '/' . $unpacking_name);383 SC_Helper_FileManager_Ex::deleteFile($dir . '/' . $unpacking_name); 422 384 // 圧縮ファイル削除 423 385 unlink($path); 424 386 return $result; 425 387 } 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 } 426 431 }
Note: See TracChangeset
for help on using the changeset viewer.
