示例#1
0
文件: RUtil.cpp 项目: rlugojr/rstudio
std::string fixPath(const std::string& path)
{
   // R sometimes gives us a path a double slashes in it ("//"). Eliminate them.
   std::string fixedPath(path);
   boost::algorithm::replace_all(fixedPath, "//", "/");
   return fixedPath;
}
示例#2
0
gs2d::SpritePtr ETHGraphicResourceManager::FindSprite(const str_type::string& fullFilePath, const str_type::string& fileName)
{
	std::map<str_type::string, SpriteResource>::iterator iter = m_resource.find(fileName);
	if (iter != m_resource.end())
	{
		str_type::string fixedPath(fullFilePath);
		Platform::FixSlashes(fixedPath);
		if (fixedPath != iter->second.m_fullOriginPath)
		{
			str_type::stringstream ss; ss << GS_L("Duplicate resource name found: ") << fixedPath
				<< GS_L(" <-> ") << iter->second.m_fullOriginPath;
			ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR);
		}
		return iter->second.m_sprite;
	}
	else
	{
		return SpritePtr();
	}
}
示例#3
0
void jvm::virtual_machine::create(const std::string &classPath)
{
	JavaVMInitArgs args;
	
	args.version = JNI_VERSION_1_2;
	
	std::string o("-Djava.class.path=");

	std::string fixedPath(classPath);
	for (size_t n = 0; n < fixedPath.size(); n++)
	{
		if (fixedPath[n] == '/' || fixedPath[n] == '\\')
		{
#ifdef CONFIG_VARIANT_windows
			#define realpath(N,R) _fullpath((R),(N),1024)
			fixedPath[n] = '\\';
#else
			fixedPath[n] = '/';
#endif
		}
	}

	char chFull[1024];
	realpath(fixedPath.c_str(), chFull);
	o += chFull;

	JavaVMOption options[1];
	options[0].optionString = const_cast<char *>(o.c_str());
	//options[1].optionString = "-verbose:jni";

	args.nOptions = sizeof(options) / sizeof(JavaVMOption);
	args.options = options;
	args.ignoreUnrecognized = JNI_FALSE;

	JNIEnv *junk;
	if (JNI_CreateJavaVM(&m_jvm, (void **)&junk, &args) < 0)
		throw std::logic_error("Could not create JavaVM");
}
示例#4
0
int main( int argc, char** argv )
{
    // init application
#if defined( QML_UI )
    QScopedPointer<QApplication> app( createApplication( argc, argv ) );
#else
    QScopedPointer<QApplication> app( new QApplication( argc, argv ) );
#endif
    app->setApplicationName( "Housing" );
    app->setApplicationVersion( "1.0.0" );
    app->setOrganizationDomain( "sodream.org" );
    app->setOrganizationName( "SoDream" );
	
#if !( defined( Q_OS_UNIX ) && !defined( Q_OS_MAC ) ) || defined( Q_OS_BLACKBERRY )
	const QStringList themesPaths = QIcon::themeSearchPaths()
#if defined( Q_OS_MACX )
        << QString( "%1/../../../Resources" ).arg( QApplication::applicationDirPath() )
#elif defined( Q_OS_BLACKBERRY )
        << QApplication::applicationDirPath()
#else
        << QApplication::applicationDirPath()
#endif
	;
	
	QIcon::setThemeSearchPaths( themesPaths );
	QIcon::setThemeName( "Oxygen" );
#endif
	
    app->setWindowIcon( QIcon::fromTheme( "go-home" ) );
    
    const QStringList paths = QStringList()
        << QLibraryInfo::location( QLibraryInfo::TranslationsPath )
        << QFileInfo( __FILE__ ).absolutePath().append( "/../translations" )
#if defined( Q_OS_MACX )
        << QString( "%1/../../../translations" ).arg( QApplication::applicationDirPath() )
#else
        << QString( "%1/translations" ).arg( QApplication::applicationDirPath() )
#endif
    ;
    
    pTranslationManager* translationManager = pTranslationManager::instance();
    translationManager->setFakeCLocaleEnabled( true );
	translationManager->addTranslationsMask( "qt*.qm" );
	translationManager->addTranslationsMask( "fresh*.qm" );
	translationManager->addTranslationsMask( "housing*.qm" );
	translationManager->addForbiddenTranslationsMask( "qt_help*.qm" );
	translationManager->setCurrentLocale( QLocale::system().name() );
    translationManager->setTranslationsPaths( paths );
    translationManager->reloadTranslations();
    
    // register drivers
    AbstractHousingDriver::registerDriver( new SeLogerHousingDriver );

    // init main window
#if defined( DESKTOP_UI ) || defined( MOBILE_UI )
    UIMain w;
    w.setWindowTitle( app->applicationName() );
    w.showMaximized();
#elif defined( QML_UI )
    QmlApplicationViewer viewer;
    viewer.addImportPath(fixedPath("modules")); // ADDIMPORTPATH
    viewer.addImportPath("/opt/Qt4.8.4/imports"); // ADDIMPORTPATH
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION
    viewer.setMainQmlFile(fixedPath("qml/main.qml")); // MAINQML
    viewer.showExpanded();
#endif

    // run application
    QObject::connect( app.data(), SIGNAL( lastWindowClosed() ), app.data(), SLOT( quit() ) );
    return app->exec();
}