예제 #1
0
 public function restoreOriginalFilename(File $aAchiveFile)
 {
     if (preg_match('/^hash[0-9A-Fa-f]{32}\\.(.+)$/s', $aAchiveFile->name(), $arrRes)) {
         return $arrRes[1];
     }
     return $aAchiveFile->name();
 }
예제 #2
0
 /**
  * @return org\jecat\framework\lang\compile\object\TokenPool
  */
 public function scan($sSourceFile)
 {
     $aSource = new String();
     $aSourceFile = new File($sSourceFile);
     $aSourceStream = $aSourceFile->openReader()->readInString($aSource);
     $aTokenPool = $this->createTokenPool($sSourceFile);
     $nLine = 1;
     $nPosition = 1;
     $arrTokens = token_get_all($aSource);
     foreach ($arrTokens as &$oneToken) {
         if (is_array($oneToken)) {
             if ($nLine != $oneToken[2]) {
                 $nLine = $oneToken[2];
                 $nPosition = 1;
             }
             $oneToken[3] = token_name($oneToken[0]);
             $aTokenPool->add(new Token($oneToken[0], $oneToken[1], $nPosition++, $nLine));
         } else {
             if (is_string($oneToken)) {
                 $aTokenPool->add(new Token(T_STRING, $oneToken, $nPosition++, $nLine));
             }
         }
     }
     return $aTokenPool;
 }
예제 #3
0
 /**
  * @return org\jecat\framework\fs\File
  */
 public function findCompiled($sSourceFile, $sNamespace, $bAutoCreate = false)
 {
     $sPath = $this->compiledFolderPath() . '/' . $this->compileStrategySignture() . '/' . Locale::singleton()->localeName() . '/' . $sNamespace . '/' . $sSourceFile . '.php';
     $aFile = new File($sPath);
     if ($bAutoCreate and !$aFile->exists()) {
         $aFile->create();
     }
     return $aFile;
 }
예제 #4
0
 public function createCompiledFile(File $aCompiledFile)
 {
     $aCompiledsDir = $aCompiledFile->directory();
     if (!$aCompiledsDir->exists()) {
         if (!$aCompiledsDir->create()) {
             throw new Exception("无法创建编译文件目录:%s", $aCompiledsDir->path());
         }
     }
     if (!$aCompiledFile->exists()) {
         $aCompiledFile->create();
     }
 }
예제 #5
0
파일: UI.php 프로젝트: JeCat/framework
 public function render(File $aCompiledFile, IHashTable $aVariables = null, IOutputStream $aDevice = null, $bPreProcess = true, $bRendering = true)
 {
     if (!$aVariables) {
         $aVariables = $this->variables();
     }
     if (!$aDevice) {
         $aDevice = $this->outputStream();
         if (!$aDevice) {
             $aDevice = Response::singleton()->printer();
         }
     }
     // 模板变量
     $aRequest = Request::singleton();
     if (!$aVariables->has('theRequest')) {
         $aVariables->set('theRequest', $aRequest);
     }
     if (!$aVariables->has('theParams')) {
         $aVariables->set('theParams', Request::singleton());
     }
     $aVariables->set('theDevice', $aDevice);
     $aVariables->set('theUI', $this);
     include $aCompiledFile->path();
 }
예제 #6
0
파일: AOP.php 프로젝트: JeCat/framework
 public function weave()
 {
     $aClassLoader = ClassLoader::singleton();
     $arrBeWeavedClasses = array();
     $aCompiler = null;
     foreach ($this->jointPointIterator() as $aJointPoint) {
         $sBeWeavedClass = $aJointPoint->weaveClass();
         if (!in_array($sBeWeavedClass, $arrBeWeavedClasses)) {
             $sSrcClassFile = $aClassLoader->searchClass($sBeWeavedClass, Package::nocompiled);
             $sCmpdClassFile = $aClassLoader->searchClass($sBeWeavedClass, Package::compiled);
             if (!$sSrcClassFile) {
                 throw new Exception("AOP 无法将目标代码织入到 JointPoint %s 中:没有找到类 %s 的源文件。", array($aJointPoint->{$sBeWeavedClass}, $aJointPoint->name()));
             }
             if (!$sCmpdClassFile) {
                 throw new Exception("AOP 无法将目标代码织入到 JointPoint %s 中:没有找到类 %s 的编译文件。", array($aJointPoint->{$sBeWeavedClass}, $aJointPoint->name()));
             }
             if (!$aCompiler) {
                 $aCompiler = $this->createClassCompiler();
             }
             $aCompiler->compile(File::createInstance($sSrcClassFile)->openReader(), File::createInstance($sCmpdClassFile)->openWriter());
             $arrBeWeavedClasses[] = $sBeWeavedClass;
         }
     }
 }
예제 #7
0
파일: File.php 프로젝트: JeCat/framework
 public function moveToStoreFolder()
 {
     if (empty($this->aStoreFolder)) {
         throw new Exception("非法的路径属性,无法依赖此路径属性创建对应的文件夹对象");
     }
     if (!$this->aStoreFolder->exists()) {
         $this->aStoreFolder = $this->aStoreFolder->create();
     }
     // 保存文件
     $sSavedFile = $this->aAchiveStrategy->makeFilePath($this->arrUploadedFile);
     $sSavedFolderPath = $this->aStoreFolder->path() . $sSavedFile;
     // 创建保存目录
     $aFolderOfSavedFile = new Folder($sSavedFolderPath);
     if (!$aFolderOfSavedFile->exists()) {
         if (!$aFolderOfSavedFile->create()) {
             throw new Exception(__CLASS__ . "的" . __METHOD__ . "在创建路径\"%s\"时出错", array($aFolderOfSavedFile->path()));
         }
     }
     $sFileName = $this->aAchiveStrategy->makeFilename($this->arrUploadedFile);
     $sSavedFullPath = $this->aStoreFolder->path() . $sSavedFile . $sFileName;
     move_uploaded_file($this->arrUploadedFile['tmp_name'], $sSavedFullPath);
     $aSavedFile = new FsFile($sSavedFullPath);
     $aSavedFile->setHttpUrl($this->aStoreFolder->httpUrl() . $sSavedFile . $sFileName);
     $this->setValue($aSavedFile);
     return $aSavedFile;
 }
예제 #8
0
파일: Folder.php 프로젝트: JeCat/framework
 public function createChildFile($sPath, $nFlag = File::CREATE_DEFAULT)
 {
     if (!($nFlag & FSO::CLEAN_PATH)) {
         $sPath = $this->path() . '/' . $sPath;
         // FSO::tidyPath($sPath,true) ;
     }
     if (is_dir($sPath)) {
         throw new Exception('试图创建File,但由于存在同名folder无法创建: %s', $sPath);
     } else {
         $aFile = new File($sPath, self::CLEAN_PATH);
         // 如果文件不存在,且没有要求 self::CREATE_ONLY_OBJECT ,则创建之
         if (!($nFlag & self::CREATE_ONLY_OBJECT) and !$aFile->exists()) {
             if (!$aFile->create($nFlag)) {
                 throw new Exception('无法创建文件:%s', $sPath);
             }
         }
     }
     return $aFile;
 }
예제 #9
0
 private function generateClassInfo($sClassName)
 {
     $aClassLoader = ClassLoader::singleton();
     $sFilePath = $aClassLoader->searchClass($sClassName, Package::nocompiled);
     if (empty($sFilePath)) {
         return array();
     }
     $aFile = new File($sFilePath);
     $aInheritInfoDetector = InheritInfoDetector::singleton();
     $arrClassInfo = $aInheritInfoDetector->detect($aFile->openReader());
     return $arrClassInfo;
 }
예제 #10
0
파일: String.php 프로젝트: JeCat/framework
 public function loadFile(File $aFile)
 {
     $aReader = $aFile->openReader();
     $nBytes = $aReader->readInString($this);
     $aReader->close();
     return $nBytes;
 }