Example #1
0
 /**
  * 将一组文件列表合并为一个文件列表
  *
  * @param array $files 文件/文件夹列表
  * @param string $packPath 打包文件存放路径
  * @param $boolean
  */
 public function pack($files, $packPath = '', $namespace = '')
 {
     $namespace = explode(' ', $namespace);
     $i = 0;
     foreach ($files as $filePath) {
         if (!($filePath = realpath($filePath))) {
             continue;
         }
         $_dir = dirname($filePath);
         $_n = isset($namespace[$i]) ? $namespace[$i] : basename($_dir);
         $_n = array(strtoupper($_n), $_dir . '/');
         $this->_import($filePath, $_n);
         $i++;
     }
     if ($this->_p && $this->fileList) {
         Wind::import('WIND:utility.WindPack');
         $pack = new WindPack();
         $pack->setContentInjectionCallBack(array($this, 'injectionImports'));
         if (!$pack->packFromFileList($this->fileList, $packPath, WindPack::STRIP_PHP, true)) {
             throw new Exception('failed to create pack file (' . $packPath . ')');
         }
     }
 }
Example #2
0
foreach ($folders as $folder) {
    $alias = '';
    if (!is_dir($folder)) {
        e("'{$folder}' is not a real directory!\n");
    }
    $alias = strtoupper(basename($folder)) . ':';
    $r = getLine("'{$folder}' is to be register as '{$alias}' ? (Y|N) ");
    if (strtolower($r[0]) != 'y') {
        $alias = getLine('Please input the relative path using namespace: ');
    }
    $fileList += readRecur(realpath($folder), $alias);
}
/* 载入需要的文件信息 */
Wind::import('WIND:utility.WindPack');
/* 打包 */
$pack = new WindPack();
$pack->packFromFileList($fileList, _COMPILE_PATH . 'wind_basic.php', WindPack::STRIP_PHP, true);
$message = array();
$message[] = "COMPILE: pack core file successful~";
/*装载imports和classes*/
$data = '<?php Wind::$_imports += ' . var_export($imports, true) . ';' . 'Wind::$_classes += ' . var_export($classes, true) . ';';
WindFile::write(_COMPILE_PATH . 'wind_imports.php', $data);
$message[] = "COMPILE: wind_imports.php successful~";
$message[] = '';
exit(implode("\n", $message));
/**
 * 递归目录
 *
 * @param string $dir
 * @return array
 */