• R/O
  • SSH
  • HTTPS

simplate: コミット


コミットメタ情報

リビジョン21 (tree)
日時2010-01-10 16:58:01
作者fujioka

ログメッセージ

bug fix #19139

変更サマリ

差分

--- trunk/simplate.cpp (revision 20)
+++ trunk/simplate.cpp (revision 21)
@@ -1598,10 +1598,9 @@
15981598 }
15991599 }
16001600
1601+DEBUG_PRINTF("write compiled file path = (%s)", const_cast<char*>(full_compile_filename.c_str()));
1602+
16011603 #ifdef PHP_WIN32
1602-
1603-DEBUG_PRINTF("write compiled file (win32) = (%s)", const_cast<char*>(full_compile_filename.c_str()));
1604-
16051604 php_stream *strm = php_stream_open_wrapper(const_cast<char*>(full_compile_filename.c_str()), "wb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
16061605 if (!strm) {
16071606
@@ -1609,9 +1608,15 @@
16091608 if (full_compile_filename.find(DEFAULT_SLASH) != string::npos) {
16101609 size_t slash_rpos = full_compile_filename.rfind("/");
16111610 size_t default_slash_rpos = full_compile_filename.rfind(DEFAULT_SLASH);
1612- slash_rpos = slash_rpos > default_slash_rpos ? slash_rpos : default_slash_rpos;
1611+
1612+DEBUG_PRINTF("slash_rpos=(%d), default_slash_rpos=(%d)", slash_rpos, default_slash_rpos);
1613+
1614+ if (slash_rpos == string::npos || slash_rpos < default_slash_rpos) {
1615+ slash_rpos = default_slash_rpos;
1616+ }
16131617 string directory_path = full_compile_filename.substr(0, slash_rpos);
16141618
1619+DEBUG_PRINTF("slash_rpos=(%d)", slash_rpos);
16151620 DEBUG_PRINTF("directory_path=(%s)", const_cast<char*>(directory_path.c_str()));
16161621
16171622 // mkdir recursively
@@ -1639,19 +1644,27 @@
16391644 // write compiled file
16401645 FILE *fp = VCWD_FOPEN(full_compile_filename.c_str(), "wb");
16411646 if (fp == NULL) {
1642- // check sub directory exists or not.
1647+ // create sub directory path
16431648 if (full_compile_filename.find(DEFAULT_SLASH) != string::npos) {
1644- vector<string> elements;
1645- split_element(const_cast<char*>(full_compile_filename.c_str()), elements, DEFAULT_SLASH);
1646- string sub_directory = elements[0];
1647- for (vector<string>::iterator i = elements.begin() + 1; i != elements.end() - 1; ++i) {
1648- sub_directory += DEFAULT_SLASH;
1649- sub_directory += (*i);
1650- struct stat cs;
1651- if (VCWD_STAT(sub_directory.c_str(), &cs) == -1) {
1652- mkdir(sub_directory.c_str(), 0755);
1653- }
1649+ size_t slash_rpos = full_compile_filename.rfind("\\");
1650+ size_t default_slash_rpos = full_compile_filename.rfind(DEFAULT_SLASH);
1651+
1652+DEBUG_PRINTF("slash_rpos=(%d), default_slash_rpos=(%d)", slash_rpos, default_slash_rpos);
1653+
1654+ if (slash_rpos == string::npos || slash_rpos < default_slash_rpos) {
1655+ slash_rpos = default_slash_rpos;
16541656 }
1657+ string directory_path = full_compile_filename.substr(0, slash_rpos);
1658+
1659+DEBUG_PRINTF("slash_rpos=(%d)", slash_rpos);
1660+DEBUG_PRINTF("directory_path=(%s)", const_cast<char*>(directory_path.c_str()));
1661+
1662+ // mkdir recursively
1663+ php_stream_context *context = NULL;
1664+ if (!php_stream_mkdir(const_cast<char*>(directory_path.c_str()), 0755, (PHP_STREAM_MKDIR_RECURSIVE | REPORT_ERRORS), context)) {
1665+ zend_error(E_ERROR, "fail to php_stream_mkdir (%s)", const_cast<char*>(directory_path.c_str()));
1666+ return;
1667+ }
16551668 }
16561669
16571670 fp = VCWD_FOPEN(full_compile_filename.c_str(), "wb");
旧リポジトリブラウザで表示