<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Chumper\Zipper\Zipper; use Illuminate\Support\Str; class ZipUtil { private static function fileTreeBuild($tBbJh) { goto TFhaE; kJr61: return $l9jHV; goto eeBBK; TFhaE: $l9jHV = array(); goto Qjvd3; Qjvd3: foreach ($tBbJh as $Jtt5u) { goto Zooiw; Zooiw: $FWwgw = explode('/', $Jtt5u['path']); goto nbInP; LekTp: foreach ($FWwgw as $Xg07i => $auep5) { goto HvEFw; AdHqs: if (!$knP9p) { goto sFse3; AVdUQ: if ($CUSvE) { $pMZ07['type'] = strtolower(pathinfo($auep5, PATHINFO_EXTENSION)); $pMZ07['size'] = $Jtt5u['size']; } else { $pMZ07['_child'] = array(); } goto w_JhC; Q3CKG: $pMZ07 = array('name' => $auep5); goto AVdUQ; Wv03I: if (!$CUSvE) { $H4Oxf =& $H4Oxf[count($H4Oxf) - 1]['_child']; } goto EZgPL; w_JhC: $H4Oxf[] = $pMZ07; goto Wv03I; sFse3: $CUSvE = $Xg07i === $Aebol - 1; goto Q3CKG; EZgPL: } goto KdeMs; GV6Kp: foreach ($H4Oxf as &$oWN8j) { if ($oWN8j['name'] === $auep5) { goto GMgJl; GMgJl: $H4Oxf =& $oWN8j['_child']; goto mZNbu; mZNbu: $knP9p = true; goto RUcCx; RUcCx: break; goto iPVBW; iPVBW: } } goto AdHqs; HvEFw: $knP9p = false; goto GV6Kp; KdeMs: } goto peC9Z; SDtIq: $Aebol = count($FWwgw); goto LekTp; nbInP: $H4Oxf =& $l9jHV; goto SDtIq; peC9Z: } goto kJr61; eeBBK: } private static function fileTreeFilter($l9jHV, $XYn5i, $boKVV = 0) { goto wxXuY; OIpma: return $M9A60; goto i1lZi; wxXuY: $M9A60 = array(); goto AsnjZ; AsnjZ: foreach ($l9jHV as $oWN8j) { if (call_user_func_array($XYn5i, array($oWN8j, $boKVV))) { goto PlwUn; Z30yc: $M9A60[] = $pMZ07; goto CpN2T; PlwUn: $pMZ07 = $oWN8j; goto bG8mM; bG8mM: if (isset($oWN8j['_child'])) { $pMZ07['_child'] = self::fileTreeFilter($oWN8j['_child'], $XYn5i, $boKVV + 1); } goto Z30yc; CpN2T: } } goto OIpma; i1lZi: } private static function fileTreeSortNodes(&$pWf7i) { usort($pWf7i, function ($RyPlq, $prNwI) { if (isset($RyPlq['type']) && isset($prNwI['type'])) { return strcmp($RyPlq['name'], $prNwI['name']); } else { if (isset($RyPlq['type'])) { return 1; } else { if (isset($prNwI['type'])) { return -1; } } } return strcmp($RyPlq['name'], $prNwI['name']); }); return $pWf7i; } private static function fileTreeSort(&$l9jHV) { goto KT1_a; KT1_a: foreach ($l9jHV as &$oWN8j) { if (isset($oWN8j['_child'])) { self::fileTreeSort($oWN8j['_child']); } } goto jr8p2; jr8p2: self::fileTreeSortNodes($l9jHV); goto jb_qh; jb_qh: return $l9jHV; goto Vxvd3; Vxvd3: } public static function fileTree($nAf_0, $nZw7W = array()) { goto Z4Gua; eZAE5: if ($nZw7W['detectRoot']) { goto doF5s; doF5s: $oIZ4g = $l9jHV; goto VxbTa; VxbTa: for (;;) { if (count($oIZ4g) > 1) { break; } if (!isset($oIZ4g[0]['_child'])) { break; } $oIZ4g = $oIZ4g[0]['_child']; } goto tw7xJ; tw7xJ: $l9jHV = $oIZ4g; goto xen_c; xen_c: } goto ynDVB; Z4Gua: if (!isset($nZw7W['ignoreSystem'])) { $nZw7W['ignoreSystem'] = true; } goto bgE5a; Zjbtn: $L4E6Y = new Zipper(); goto FISs6; WJ0an: if (!isset($nZw7W['maxDepth'])) { $nZw7W['maxDepth'] = 0; } goto iVsZu; k1bM3: $l9jHV = self::fileTreeBuild($tBbJh); goto iTsdR; FISs6: $L4E6Y->make($nAf_0); goto IOLCL; ynDVB: if ($nZw7W['maxDepth'] > 0) { $l9jHV = self::fileTreeFilter($l9jHV, function ($oWN8j, $boKVV) use($nZw7W) { return $boKVV < $nZw7W['maxDepth']; }); } goto kiWBw; iTsdR: if ($nZw7W['ignoreSystem']) { $l9jHV = self::fileTreeFilter($l9jHV, function ($oWN8j, $boKVV) { if (isset($oWN8j['type'])) { if (in_array($oWN8j['type'], array('DS_Store'))) { return false; } } else { if (in_array($oWN8j['name'], array('__MACOSX'))) { return false; } } return true; }); } goto lmkFT; GkHHY: $tBbJh = ArrayUtil::sortByKey($tBbJh, 'path'); goto k1bM3; hCG_D: $L4E6Y->close(); goto GkHHY; IOLCL: $tBbJh = array(); goto g4D0P; bgE5a: if (!isset($nZw7W['ignoreHidden'])) { $nZw7W['ignoreHidden'] = true; } goto WJ0an; g4D0P: $L4E6Y->getRepository()->each(function ($f0dxO, $EDh03) use(&$tBbJh) { $tBbJh[] = array('path' => str_replace('\\', '/', $f0dxO), 'size' => $EDh03['size']); }); goto hCG_D; kiWBw: return self::fileTreeSort($l9jHV); goto AtNRB; iVsZu: if (!isset($nZw7W['detectRoot'])) { $nZw7W['detectRoot'] = false; } goto Zjbtn; lmkFT: if ($nZw7W['ignoreHidden']) { $l9jHV = self::fileTreeFilter($l9jHV, function ($oWN8j, $boKVV) { if (Str::startsWith($oWN8j['name'], '.')) { return false; } return true; }); } goto eZAE5; AtNRB: } }