Example #1
0
 /**
  * キャッシュされたtgzの削除
  */
 public static function rm()
 {
     if (is_dir(self::$tgz_dir)) {
         foreach (File::ls(self::$tgz_dir, true) as $file) {
             File::rm($file->fullname());
         }
         foreach (File::dirs(self::$tgz_dir, true) as $dir) {
             File::rm($dir);
         }
     }
 }
Example #2
0
File: Chat.php Project: riaf/ringl
 private static function get_pids()
 {
     $pids = array();
     $files = File::ls(work_path());
     foreach ($files as $file) {
         if ($file->ext() == '.pid') {
             $pids[] = intval($file->oname());
         }
     }
     return $pids;
 }
Example #3
0
File: Test.php Project: hisaboh/w2t
 /**
  * ディエクトリパスを指定してテストを実行する
  * @param string $path
  * @return Test
  */
 public static final function verifies($path)
 {
     foreach (File::ls($path, true) as $file) {
         if ($file->fullname() !== __FILE__ && $file->isClass()) {
             ob_start();
             include_once $file->fullname();
             Rhaco::import($file->oname());
             ob_get_clean();
             self::verify($file->oname());
         }
     }
     return new self();
 }
Example #4
0
File: Crud.php Project: hisaboh/w2t
 private function search_model()
 {
     $models = array();
     foreach (File::ls(Rhaco::path(), true) as $file) {
         if ($file->isClass()) {
             ob_start();
             include_once $file->fullname();
             ob_end_clean();
             if (is_implements_of($file->oname(), "Model")) {
                 $models[] = $file;
             }
         }
     }
     return $models;
 }
Example #5
0
 /**
  * 指定のディレクトリ内の.phpファイルのCRLFをLFに変換する
  * 
  * @param string $path
  */
 public static function crlf2lf($path)
 {
     foreach (File::ls($path, true) as $file) {
         if ($file->ext() == ".php") {
             File::write($file->fullname(), str_replace(array("\r\n", "\r"), "\n", $file->get()));
         }
     }
 }
Example #6
0
 /**
  * 最終更新時間を取得
  * @param string $filename ファイルパス
  * @param boolean $clearstatcache ファイルのステータスのキャッシュをクリアするか
  * @return integer
  */
 public static function last_update($filename, $clearstatcache = false)
 {
     if ($clearstatcache) {
         clearstatcache();
     }
     if (is_dir($filename)) {
         $last_update = -1;
         foreach (File::ls($filename, true) as $file) {
             if ($last_update < $file->update()) {
                 $last_update = $file->update();
             }
         }
         return $last_update;
     }
     return is_readable($filename) && is_file($filename) ? filemtime($filename) : -1;
 }
Example #7
0
    /**
     * potファイルを作成する
     * @param string $path potを生成する対象のルートパス
     * @param string $lc_messages_path potファイルを出力するパス
     * @return string potファイルを出力したパス
     */
    public static function generate_pot($path, $lc_messages_path = null)
    {
        if (empty($lc_messages_path)) {
            $lc_messages_path = "messages.pot";
        }
        $messages = array();
        foreach (File::ls($path, true) as $file) {
            if ($file->size() < 1024 * 1024) {
                $src = File::read($file);
                foreach (explode("\n", $src) as $line => $value) {
                    if (preg_match_all("/__\\(([\"\\'])(.+?)\\1/", $value, $match)) {
                        foreach ($match[2] as $msg) {
                            $messages[$msg]["#: " . str_replace($path, "", $file->fullname()) . ":" . ($line + 1)] = true;
                        }
                    }
                    if (preg_match_all("/App::trans\\(([\"\\'])(.+?)\\1/", $value, $match)) {
                        foreach ($match[2] as $msg) {
                            $messages[$msg]["#: " . str_replace($path, "", $file->fullname()) . ":" . ($line + 1)] = true;
                        }
                    }
                }
            }
        }
        ksort($messages, SORT_STRING);
        $output_src = sprintf(Text::plain('
						# SOME DESCRIPTIVE TITLE.
						msgid ""
						msgstr ""
						"Project-Id-Version: PACKAGE VERSION\\n"
						"Report-Msgid-Bugs-To: \\n"
						"POT-Creation-Date: %s\\n"
						"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
						"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
						"Language-Team: LANGUAGE <*****@*****.**>\\n"
						"Plural-Forms: nplurals=1; plural=0;\\n"
				'), date("Y-m-d H:iO")) . "\n\n";
        foreach ($messages as $str => $lines) {
            $output_src .= "\n" . implode("\n", array_keys($lines)) . "\n";
            $output_src .= "msgid \"" . $str . "\"\n";
            $output_src .= "msgstr \"\"\n";
        }
        if (is_file($lc_messages_path)) {
            throw new InvalidArgumentException($lc_messages_path . ": File exists");
        }
        File::write($lc_messages_path, $output_src);
        return $lc_messages_path;
    }
Example #8
0
 /**
  * ディエクトリパスを指定してテストを実行する
  * @param string $path
  * @return Test
  */
 public static final function verifies()
 {
     foreach (Lib::classes(true) as $path => $class) {
         self::verify($path);
     }
     if (is_dir(self::path())) {
         foreach (File::ls(self::path(), true) as $f) {
             $dir = str_replace(self::path(), "", $f->directory());
             if (substr($dir, 0, 1) == "/") {
                 $dir = substr($dir, 1);
             }
             if (substr($dir, -1) == "/") {
                 $dir = substr($dir, 0, -1);
             }
             self::verify(str_replace("/", ".", empty($dir) ? "" : $dir . ".") . preg_replace("/_test\$/", "", $f->oname()));
         }
     }
     return new self();
 }
Example #9
0
$rsl = path("flex/rsl/");
while (true) {
    $lib_last_update = $src_last_update = $rsl_last_update = $id = 0;
    $mxmlc = sprintf("mxmlc -output %s --file-specs %s ", $bin, $src);
    if ($lib_last_update < ($lib_update = File::last_update($lib, true))) {
        $lib_last_update = $lib_update;
        $files = array();
        foreach (File::ls($lib) as $f) {
            $files[] = $f->fullname();
        }
        $mxmlc .= "-library-path+=" . implode(",", $files) . " ";
    }
    if ($rsl_last_update < ($rsl_update = File::last_update($rsl, true))) {
        $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;
        }
Example #10
0
 /**
  * vendorsを更新する
  */
 public static function vendors_update()
 {
     self::set_path();
     if (is_dir(self::$vendor_path)) {
         File::rm(self::$vendor_path, false);
     }
     foreach (Lib::classes(true, true) as $key => $class) {
         Lib::import($key);
     }
     foreach (File::ls(App::path()) as $f) {
         if ($f->is_ext('php')) {
             $src = File::read($f);
             if (preg_match_all("/[^\\w](import|R|C)\\(([\"\\'])(.+?)\\2\\)/", $src, $match)) {
                 foreach ($match[3] as $path) {
                     try {
                         self::import(trim($path));
                     } catch (Exception $e) {
                     }
                 }
             }
             if (Tag::setof($tag, $src, 'app')) {
                 if (preg_match_all("/[^\\w]class=([\"\\'])(.+?)\\1/", $src, $match)) {
                     foreach ($match[2] as $path) {
                         try {
                             self::import(trim($path));
                         } catch (Exceptions $e) {
                         }
                     }
                 }
             }
         }
     }
 }