/** * $keyが存在するか * @param string $key キー名 * @param boolean $ignore_time 有効期限 * @return boolean */ public static function has($key, $ignore_time = false) { $id = self::id($key); if (Object::C(__CLASS__)->has_module("store_has")) { return Object::C(__CLASS__)->call_module("store_has", $id, $ignore_time); } $path = File::absolute(App::work("store"), $id); $path = is_file($path) ? $path : (is_file($path . "_s") ? $path . "_s" : null); if ($ignore_time && $path !== null) { return true; } return isset($path) && File::last_update($path) > time(); }
private static function app($repository) { if (!$repository->start("app")) { return; } if (is_dir(App::path("apps"))) { $list = array(); foreach (File::dir(App::path("apps"), true) as $dir) { $bool = true; foreach ($list as $p) { if (strpos($dir, $p) === 0) { $bool = false; break; } } if ($bool) { $package = str_replace(array(App::path("apps/"), "/"), array("", "."), $dir); $info = App::info($dir); if (!empty($info["name"])) { $tgz_filename = $repository->tgz_path($package); File::tgz($tgz_filename, $dir); touch($tgz_filename, File::last_update($dir)); $repository->add($package, $info["name"], File::last_update($dir), $info["description"], $info["summary"]); $list[] = $dir; } } } } }
protected function __new__($path, $detail = true) { list($ref, $class, $path) = self::reflection_class($path); $parent = $ref->getParentClass(); if ($parent !== false && $parent->getName() !== "stdClass") { $i = new self($parent->getName(), false); $this->extends($i->fm_package()); } $this->name($ref->getName()); $this->updated(File::last_update($ref->getFileName())); $this->path(str_replace("\\", "/", $ref->getFileName())); try { $this->package(Lib::package_path($this->path())); if ($ref->getName() != substr($this->package, ($p = strrpos($this->package, ".")) + ($p === false ? 0 : 1))) { $package_path = str_replace('.', '/', $this->package) . '/'; list($module, $null) = explode('.', substr($this->path, strpos($this->path, $package_path) + strlen($package_path))); $this->module = str_replace('/', '.', $module); } } catch (RuntimeException $e) { } if ($this->is_path()) { $class_src = str_replace(array("\r\n", "\r"), "\n", File::read($this->path())); $this->valid_line(sizeof(explode("\n", preg_replace("/^[\\s\t\n\r]*" . "/sm", "", preg_replace("/\\/\\*.*?\\*\\//s", "", $class_src))))); if (preg_match_all('/module_const\\((["\'])(.+?)\\1/', $class_src, $match)) { foreach ($match[2] as $n) { $this->def[$this->package() . '@' . $n] = new InfoAt($this->package() . '@' . $n, $this->package()); } } if (preg_match_all("/@const[\\s]+(.+)/", $class_src, $match)) { foreach ($match[1] as $m) { InfoAt::merge($this->def, $m, $this->package(), $this->package() . '@'); } } if (preg_match_all("/(\\/\\/|#)[\\s]*TODO[\t ]+(.+)/", $class_src, $todos)) { foreach ($todos[2] as $v) { $this->tasks[] = trim($v); } } if ($detail) { $pure_class_src = explode("\n", $class_src); foreach ($ref->getMethods() as $method) { $mname = $method->getName(); if (($mname[0] != '_' || $mname == '__init__' || strpos($mname, "__setup_") === 0) && (!$this->is_methods($mname) && !$this->is_setup($mname))) { $package = $this->package(); if (empty($package)) { $package = $this->name(); } $mobj = new InfoMethod($package, $this->name(), $method); if ($mobj->is_static() && $mobj->pure_perm() == "public" && strpos($mname, "__setup_") === 0 && substr($mname, -2) === "__") { $this->setup($mobj->name(), $mobj); } else { if ($mobj->name() == '__init__') { if (!$this->is_init()) { $this->init($mobj); } } else { $this->methods($mobj->name(), $mobj); } } if (!$mobj->is_extends()) { for ($i = $method->getStartLine() - 1; $i < $method->getEndLine(); $i++) { $pure_class_src[$i] = ""; } } } } ksort($this->methods); $this->class_method = new InfoMethod($this->package(), $this->name(), null); foreach (InfoDoctest::get(implode("\n", $pure_class_src), $this->name(), $this->package()) as $k => $v) { $this->class_method->test($k, $v); } foreach ($ref->getDefaultProperties() as $k => $v) { if ($k == "_mixin_" && !empty($v)) { foreach (explode(",", $v) as $o) { $r = new self($o); $this->mixin_object[] = $r->package() == "" ? $r->name() : $r->package(); } break; } } if (is_subclass_of($class, "Flow") && $this->is_init()) { foreach ($this->methods() as $k => $v) { $this->methods[$k]->context(array_merge($this->init()->context(), $v->context())); $this->methods[$k]->request(array_merge($this->init()->request(), $v->request())); } } if (is_subclass_of($class, "Object")) { $ex_src = array(); $search_src = null; $default_properties = $ref->getDefaultProperties(); foreach ($ref->getProperties() as $prop) { if (!$prop->isPrivate()) { $name = $prop->getName(); if ($name[0] != "_" && !$prop->isStatic()) { $this->properties[$name] = new InfoAt($name, $this->package()); if ($prop->getDocComment() != "") { $this->properties[$name]->document(str_replace(array("\r", "\n"), "", trim(preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", "", str_replace(array("/" . "**", "*" . "/"), "", $prop->getDocComment()))))); } else { if ($prop->getDeclaringClass()->getName() == $class) { $search_src = $class_src; } else { $class_name = $prop->getDeclaringClass()->getName(); if (!isset($ex_src[$class_name])) { $ex_src[$class_name] = File::read($prop->getDeclaringClass()->getFileName()); } $search_src = $ex_src[$class_name]; } if (preg_match("/[\\s]+(public|protected)[\\s]+\\\$" . $name . ".*;.*#(.+)/", $search_src, $match)) { $this->properties[$name]->document(trim($match[2])); } } if (isset($default_properties['__' . $name . '__'])) { $this->properties[$name]->set_anon($default_properties['__' . $name . '__']); } } } } unset($search_src); } } } $this->document(trim(preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", "", str_replace(array("/" . "**", "*" . "/"), "", $ref->getDocComment())))); }
$rsl_last_update = $rsl; $files = array(); foreach (File::ls($rsl) as $f) { $files[] = $f->fullname(); $names[] = "../rsl/" . $f->name(); } $mxmlc .= "-runtime-shared-libraries=" . implode(",", $names) . " "; $mxmlc .= "-external-library-path=" . implode(",", $files) . " "; } $cmd->write($mxmlc); while (true) { $line = $cmd->gets(); if (strpos($line, "(fcsh)") === 0) { if (preg_match("/(\\d+)/", $line, $match)) { $id = $match[1]; } break; } } while (true) { if ($lib_last_update < File::last_update($lib, true)) { break; } if (($src_update = File::last_update($src, true)) > $src_last_update) { $cmd->write(sprintf("compile %s", $id)); println("compile " . date("Y/m/d H:i:s")); $src_last_update = $src_update; } sleep(1); } }