<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Chumper\Zipper\Zipper; use Illuminate\Support\Str; class ZipUtil { private static function fileTreeBuild($zdxah) { goto Fz0xV; I1OyI: foreach ($zdxah as $ypGny) { goto wY5Vy; CFF41: foreach ($ar3hF as $JmnHl => $JlsAT) { goto jVXfK; MwO8J: if (!$lNQUI) { goto qVvQ9; qVvQ9: $iWXYb = $JmnHl === $PDP0L - 1; goto JUt93; ZOZxO: if (!$iWXYb) { $KW6Nl =& $KW6Nl[count($KW6Nl) - 1]['_child']; } goto Szwch; syrZU: if ($iWXYb) { $ZI0jO['type'] = strtolower(pathinfo($JlsAT, PATHINFO_EXTENSION)); $ZI0jO['size'] = $ypGny['size']; } else { $ZI0jO['_child'] = array(); } goto s2xU_; JUt93: $ZI0jO = array('name' => $JlsAT); goto syrZU; s2xU_: $KW6Nl[] = $ZI0jO; goto ZOZxO; Szwch: } goto NCO3t; jVXfK: $lNQUI = false; goto JuHYd; JuHYd: foreach ($KW6Nl as &$BTwbY) { if ($BTwbY['name'] === $JlsAT) { goto irpVW; PEHEl: break; goto NjsB3; z5QUM: $lNQUI = true; goto PEHEl; irpVW: $KW6Nl =& $BTwbY['_child']; goto z5QUM; NjsB3: } } goto MwO8J; NCO3t: } goto kYpEV; wY5Vy: $ar3hF = explode('/', $ypGny['path']); goto eiVPw; eiVPw: $KW6Nl =& $o1nCG; goto ON8Po; ON8Po: $PDP0L = count($ar3hF); goto CFF41; kYpEV: } goto W6_Gu; Fz0xV: $o1nCG = array(); goto I1OyI; W6_Gu: return $o1nCG; goto TFHCL; TFHCL: } private static function fileTreeFilter($o1nCG, $Nxn6E, $EL7D3 = 0) { goto HnpOY; zlj_s: return $JY5IR; goto DDtxu; f0pSZ: foreach ($o1nCG as $BTwbY) { if (call_user_func_array($Nxn6E, array($BTwbY, $EL7D3))) { goto Jg3ZX; Q9_qO: $JY5IR[] = $ZI0jO; goto isIsS; j8Qvp: if (isset($BTwbY['_child'])) { $ZI0jO['_child'] = self::fileTreeFilter($BTwbY['_child'], $Nxn6E, $EL7D3 + 1); } goto Q9_qO; Jg3ZX: $ZI0jO = $BTwbY; goto j8Qvp; isIsS: } } goto zlj_s; HnpOY: $JY5IR = array(); goto f0pSZ; DDtxu: } private static function fileTreeSortNodes(&$SLm7t) { usort($SLm7t, function ($BxryP, $Y7i7h) { if (isset($BxryP['type']) && isset($Y7i7h['type'])) { return strcmp($BxryP['name'], $Y7i7h['name']); } else { if (isset($BxryP['type'])) { return 1; } else { if (isset($Y7i7h['type'])) { return -1; } } } return strcmp($BxryP['name'], $Y7i7h['name']); }); return $SLm7t; } private static function fileTreeSort(&$o1nCG) { goto w62k8; VksJG: return $o1nCG; goto yhPQQ; w62k8: foreach ($o1nCG as &$BTwbY) { if (isset($BTwbY['_child'])) { self::fileTreeSort($BTwbY['_child']); } } goto FdcAl; FdcAl: self::fileTreeSortNodes($o1nCG); goto VksJG; yhPQQ: } public static function fileTree($YhsOb, $Ggr9v = array()) { goto N3vY6; N0RzZ: if (!isset($Ggr9v['maxDepth'])) { $Ggr9v['maxDepth'] = 0; } goto PmjTp; E0UMY: return self::fileTreeSort($o1nCG); goto FfZ7P; LH7aQ: $lKJNE->getRepository()->each(function ($ZZMEd, $KGUH1) use(&$zdxah) { $zdxah[] = array('path' => str_replace('\\', '/', $ZZMEd), 'size' => $KGUH1['size']); }); goto PaMQE; PaMQE: $lKJNE->close(); goto Aph76; urzAx: if ($Ggr9v['ignoreSystem']) { $o1nCG = self::fileTreeFilter($o1nCG, function ($BTwbY, $EL7D3) { if (isset($BTwbY['type'])) { if (in_array($BTwbY['type'], array('DS_Store'))) { return false; } } else { if (in_array($BTwbY['name'], array('__MACOSX'))) { return false; } } return true; }); } goto ACagj; fdkTF: $zdxah = array(); goto LH7aQ; i6UIy: $lKJNE = new Zipper(); goto VRkuk; hqBme: if ($Ggr9v['maxDepth'] > 0) { $o1nCG = self::fileTreeFilter($o1nCG, function ($BTwbY, $EL7D3) use($Ggr9v) { return $EL7D3 < $Ggr9v['maxDepth']; }); } goto E0UMY; VxPGj: if (!isset($Ggr9v['ignoreHidden'])) { $Ggr9v['ignoreHidden'] = true; } goto N0RzZ; PmjTp: if (!isset($Ggr9v['detectRoot'])) { $Ggr9v['detectRoot'] = false; } goto i6UIy; kbQXb: $o1nCG = self::fileTreeBuild($zdxah); goto urzAx; NHF_8: if ($Ggr9v['detectRoot']) { goto GXRpL; VbjwJ: for (;;) { if (count($Av85E) > 1) { break; } if (!isset($Av85E[0]['_child'])) { break; } $Av85E = $Av85E[0]['_child']; } goto isihq; isihq: $o1nCG = $Av85E; goto VbCkT; GXRpL: $Av85E = $o1nCG; goto VbjwJ; VbCkT: } goto hqBme; ACagj: if ($Ggr9v['ignoreHidden']) { $o1nCG = self::fileTreeFilter($o1nCG, function ($BTwbY, $EL7D3) { if (Str::startsWith($BTwbY['name'], '.')) { return false; } return true; }); } goto NHF_8; VRkuk: $lKJNE->make($YhsOb); goto fdkTF; N3vY6: if (!isset($Ggr9v['ignoreSystem'])) { $Ggr9v['ignoreSystem'] = true; } goto VxPGj; Aph76: $zdxah = ArrayUtil::sortByKey($zdxah, 'path'); goto kbQXb; FfZ7P: } }