void applyBinding(lua_State * L) { // Connect LuaBind to this state try { luabind::open(L); luabind::bind_class_info(L); } catch (const std::exception & e) { std::cerr << "Caught exception connecting luabind and class_info: " << e.what() << std::endl; throw; } /// Apply our bindings to this state // Extend the lua script search path for "require" LuaPath& lp = LuaPath::instance(); { LuaSearchPathUpdater searchpath(L); searchpath.extend(SearchDirectory(lp.getLuaDir())); searchpath.extend(RootDirectory(lp.getRootDir())); } { /// @todo c search path //LuaCSearchPathUpdater csearchpath(L); } // osgLua bindOsgToLua(L); // vrjugglua bindKernelToLua(L); bindSonixToLua(L); bindGadgetInterfacesToLua(L); bindRunBufferToLua(L); BindvrjLuaToLua(L); OsgAppProxy::bindToLua(L); // Set up traceback... luabind::set_pcall_callback(&add_file_and_line); // Load the vrjlua init script luabind::globals(L)["require"]("vrjlua-init"); // set up global for debug mode /// @todo make this work /* luabind::module(L.get(), "vrjlua")[ luabind::def_readwrite(boost::ref(LuaScript::exitOnError)) ]; */ }
FString FFileManagerGeneric::DefaultConvertToRelativePath( const TCHAR* Filename ) { //default to the full absolute path of this file FString RelativePath( Filename ); FPaths::NormalizeFilename(RelativePath); // See whether it is a relative path. FString RootDirectory( FPlatformMisc::RootDir() ); FPaths::NormalizeFilename(RootDirectory); //the default relative directory it to the app root which is 3 directories up from the starting directory int32 NumberOfDirectoriesToGoUp = 3; //temp holder for current position of the slash int32 CurrentSlashPosition; //while we haven't run out of parent directories until we which a drive name while( ( CurrentSlashPosition = RootDirectory.Find( TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd ) ) != INDEX_NONE ) { if( RelativePath.StartsWith( RootDirectory ) ) { FString BinariesDir = FString(FPlatformProcess::BaseDir()); FPaths::MakePathRelativeTo( RelativePath, *BinariesDir ); break; } int32 PositionOfNextSlash = RootDirectory.Find( TEXT("/"), ESearchCase::CaseSensitive, ESearchDir::FromEnd, CurrentSlashPosition ); //if there is another slash to find if( PositionOfNextSlash != INDEX_NONE ) { //move up a directory and on an extra .. TEXT("/") // the +1 from "InStr" moves to include the "\" at the end of the directory name NumberOfDirectoriesToGoUp++; RootDirectory = RootDirectory.Left( PositionOfNextSlash + 1 ); } else { RootDirectory.Empty(); } } return RelativePath; }