Sorry, I should have explained it better...

The solution provided allows for seamless change of the root path for all
the scripts in the ScriptingCore. Say you could do something like (pseudo
code)

'''
#ifdef SIMULATOR
ScriptingCore->getInstance()->sertExternalScriptPath("/PATH/ON/HOST");
#endif
'''

And all ''runScript'' and ''require'' calls in JS go through to the host.
No changes in JS required.

I hope that explains it better.
On Feb 20, 2013 7:51 PM, "James Chen" <notifications@github.com> wrote:

> In scripting/javascript/bindings/ScriptingCore.cpp:
>
> >          rpath = futil->fullPathForFilename(path);
> >      }
> > +
>
> Is externalScriptPath necessary?
> The logic in CCFileUtils::fullPathForFilename will check whether the pathpassed in is a relative or absolute path.
> Therefore, i think
>
>
> if (this->externalScriptPath == "") {
>         const char * tmp;
>
>         if (path[0] == '/') {
>             tmp = path;
>         } else {
>             cocos2d::CCFileUtils * futil = cocos2d::CCFileUtils::sharedFileUtils();
>             tmp = futil->fullPathFromRelativePath(path);
>
>             if (!tmp) {
>                 CCLOG("!tmp. returning JS_FALSE");
>                 return JS_FALSE;
>             }
>         }
>
>         rpath = tmp;
>     } else {
>         cocos2d::CCFileUtils * futil = cocos2d::CCFileUtils::sharedFileUtils();
>         rpath = futil->fullPathForFilename(path);
>     }
>
> is not needed.
> PLZ look at the implementation of CCFileUtils::fullPathForFilename
>
>
> std::string CCFileUtils::fullPathForFilename(const char* pszFileName)
> {
>     CCAssert(pszFileName != NULL, "CCFileUtils: Invalid path");
>
>     std::string strFileName = pszFileName;
>     if (isAbsolutePath(pszFileName))   // We check whether the path is an absolute path here.
>     {
>         //CCLOG("Return absolute path( %s ) directly.", pszFileName);
>         return pszFileName;
>     }
>
>  --
> Reply to this email directly or view it on GitHub<https://github.com/cocos2d/cocos2d-x/pull/2017/files#r3093367>.
>
>