From b15ad533ed8954c303a648a6e1d7be3375832f2b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 5 Mar 2014 15:45:25 +0800 Subject: [PATCH] issue #4234: Checking whether '.jsc' file exists. --- .../js-bindings/bindings/manual/ScriptingCore.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp b/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp index 1e6fa95c6a..29a914f6dc 100644 --- a/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp +++ b/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp @@ -547,12 +547,15 @@ void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext* // a) check jsc file first std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; - Data data = futil->getDataFromFile(byteCodePath); - - if (!data.isNull()) - { - script = JS_DecodeScript(cx, data.getBytes(), static_cast(data.getSize()), nullptr, nullptr); - } + // Check whether '.jsc' files exist to avoid outputing log which says 'couldn't find .jsc file'. + if (futil->isFileExist(byteCodePath)) + { + Data data = futil->getDataFromFile(byteCodePath); + if (!data.isNull()) + { + script = JS_DecodeScript(cx, data.getBytes(), static_cast(data.getSize()), nullptr, nullptr); + } + } // b) no jsc file, check js file if (!script)