/** * 比较配置文件的MD5,如果没有改变返回false,否则返回true * * @return bool * @throws InitiallyRpcException */ private function compareConfigFile() { $cachePath = INITIALLY_RPC_ROOT_PATH . "/src"; $cacheFile = $cachePath . "/info.cache"; Util::createDirIfNotExists($cachePath); $configSha1 = sha1_file($this->configFile); if (!is_file($cacheFile)) { if (!@file_put_contents($cacheFile, $configSha1)) { throw new InitiallyRpcException("write config file md5 failed"); } $oldConfigSha1 = $configSha1; } else { $oldConfigSha1 = file_get_contents($cacheFile); if ($configSha1 != $oldConfigSha1 && !@file_put_contents($cacheFile, $configSha1)) { throw new InitiallyRpcException("write config file md5 failed"); } } return $configSha1 == $oldConfigSha1; }
/** * Get proxy class dir and create it * * @param string $namespace * @return string * @throws InitiallyRpcException */ protected function getProxyClassDirAndCreate($namespace) { $path = str_replace("\\", DIRECTORY_SEPARATOR, $namespace); $dir = $this->config->getProxyRootDir() . DIRECTORY_SEPARATOR . $path; if (!Util::createDirIfNotExists($dir)) { throw new InitiallyRpcException("Proxy builder error: get proxy class dir and create it"); } return $dir; }