Ejemplo n.º 1
0
void ElectronPairProduction::setPhotonField(PhotonField photonField) {
    this->photonField = photonField;
    std::string fname = photonFieldName(photonField);
    setDescription("ElectronPairProduction: " + fname);
    initRate(getDataPath("ElectronPairProduction/lossrate_" + fname + ".txt"));
    initSpectrum(getDataPath("ElectronPairProduction/spectrum_" + fname.substr(0,3) + ".txt"));
}
Ejemplo n.º 2
0
    void ResourceManager::loadGlowingTiles()
    {
        int size = 0;
        char *buffer;
        if (getDataPath("glowtile_red").find(".zip") == std::string::npos)
        {
            graphicsEngine->loadTexture(getDataPath("glowtile_red.png"));
        }
        else
        {
            buffer = loadFile("glowtile_red.png", size);
            graphicsEngine->loadTexture("glowtile_red.png", buffer, size);
            free(buffer);
        }

        if (getDataPath("glowtile_green").find(".zip") == std::string::npos)
        {
            graphicsEngine->loadTexture(getDataPath("glowtile_green.png"));
        }
        else
        {
            size = 0;
            buffer = loadFile("glowtile_green.png", size);
            graphicsEngine->loadTexture("glowtile_green.png", buffer, size);
            free(buffer);
        }
    }
Ejemplo n.º 3
0
/////////////////////LEVEL SELECT/////////////////////
LevelPlaySelect::LevelPlaySelect(ImageManager& imageManager, SDL_Renderer& renderer)
    :LevelSelect(imageManager,renderer,_("Select Level")),
      levelInfoRender(imageManager,renderer,getDataPath(),*fontText,themeTextColor){
	//Load the play button if needed.
    playButtonImage=imageManager.loadTexture(getDataPath()+"gfx/playbutton.png", renderer);
	
	//Create the gui.
    createGUI(imageManager,renderer, true);
	
	//Show level list
    refresh(imageManager,renderer);
}
Ejemplo n.º 4
0
void Prototype01::selfSetup(){
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    
    colorEdgesShader.loadFrag(getDataPath()+"shaders/colorEdges.frag");
    colorExtractionShader.loadFrag(getDataPath()+"shaders/colorExtraction.frag");
    complementColorShader.loadFrag(getDataPath()+"shaders/complementColor.frag");
    
    medianFilter.allocate(ofGetScreenWidth(), ofGetScreenHeight());
    colorExtractedFbo.allocate(ofGetScreenWidth(), ofGetScreenHeight());
    complementColorFbo.allocate(ofGetScreenWidth(), ofGetScreenHeight());
    bApplyMedian = false;
}
Ejemplo n.º 5
0
void PhotoPionProduction::setPhotonField(PhotonField field) {
	photonField = field;
	if (haveRedshiftDependence) {
		std::cout << "PhotoPionProduction: tabulated redshift dependence not needed for CMB, switching off" << std::endl;
		haveRedshiftDependence = false;
	}
	std::string fname = photonFieldName(field);
	setDescription("PhotoPionProduction: " + fname);
	if (haveRedshiftDependence)
		initRate(getDataPath("PhotoPionProduction/rate_" + fname.replace(0, 3, "IRBz") + ".txt"));
	else
		initRate(getDataPath("PhotoPionProduction/rate_" + fname + ".txt"));
}
Ejemplo n.º 6
0
PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint,
            testing::Combine(
                testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64),
                InpaintingMethod::all()
                )
            )
{
    Mat src = imread(getDataPath("gpu/hog/road.png"));

    Size sz = get<0>(GetParam());
    int inpaintingMethod = get<1>(GetParam());

    Mat mask(src.size(), CV_8UC1, Scalar(0));
    Mat result(src.size(), src.type());

    Rect inpaintArea(src.cols/3, src.rows/3, sz.width, sz.height);
    mask(inpaintArea).setTo(255);

    declare.in(src, mask).out(result).time(120);

    TEST_CYCLE() inpaint(src, mask, result, 10.0, inpaintingMethod);

    Mat inpaintedArea = result(inpaintArea);
    SANITY_CHECK(inpaintedArea);
}
Ejemplo n.º 7
0
std::string CrossPlatform::findFalltergeistDataPath()
{
    if (_falltergeistDataPath.length() > 0)
        return _falltergeistDataPath;
    Logger::info() << "Looking for Falltergeist data files" << std::endl;
    std::vector<std::string> directories;
    directories.push_back(getCurrentDirectory());
    directories.push_back(getDataPath());

    for (auto &directory : directories)
    {
        std::ifstream stream(directory + "/data/dialogs.lst");
        if (stream)
        {
            Logger::info() << "Searching in directory: " << directory << " data/dialogs.lst [FOUND]" << std::endl;
            _falltergeistDataPath = directory;
            return _falltergeistDataPath;
        }
        else
        {
            Logger::info() << "Searching in directory: " << directory << " data/dialogs.lst [NOT FOUND]" << std::endl;
        }
    }

    throw Exception("Falltergeist data files are not found!");
}
Ejemplo n.º 8
0
INT_PTR CMimAPI::foldersPathChanged()
{
	TCHAR szTemp[MAX_PATH + 2] = {'\0'};

	if (m_hDataPath) {
		FoldersGetCustomPathT(m_hDataPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getDataPath()));
		mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%s"), szTemp);

		FoldersGetCustomPathT(m_hSkinsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSkinPath()));
		mir_sntprintf(m_szSkinsPath, MAX_PATH - 1, _T("%s"), szTemp);
		Utils::ensureTralingBackslash(m_szSkinsPath);

		FoldersGetCustomPathT(m_hAvatarsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSavedAvatarPath()));
		mir_sntprintf(m_szSavedAvatarsPath, MAX_PATH, _T("%s"), szTemp);

		FoldersGetCustomPathT(m_hChatLogsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getChatLogPath()));
		mir_sntprintf(m_szChatLogsPath, MAX_PATH, _T("%s"), szTemp);
		Utils::ensureTralingBackslash(m_szChatLogsPath);
	}

	CreateDirectoryTreeT(m_szProfilePath);
	CreateDirectoryTreeT(m_szSkinsPath);
	CreateDirectoryTreeT(m_szSavedAvatarsPath);

	Skin->extractSkinsAndLogo(true);
	Skin->setupAeroSkins();
	return 0;
}
Ejemplo n.º 9
0
void FileUtils::setResource(const char* pszZipFileName)
{
    // get the full path of zip file
    char fullPath[EOS_FILE_MAX_PATH] = {0};
    if (strlen(s_ResourcePath))
    {
        strcpy(fullPath, s_ResourcePath);
    }
    else
    {
        const char* pAppDataPath = getDataPath();
        strcpy(fullPath, pAppDataPath);
    }
    strcat(fullPath, pszZipFileName);

    // if the zip file not exist,use message box to warn developer
    TUChar pszTmp[EOS_FILE_MAX_PATH] = {0};
    TUString::StrGBToUnicode(pszTmp, (const Char*) fullPath);
    Boolean bExist = EOS_IsFileExist(pszTmp);
    if (!bExist)
    {
        std::string strErr = "zip file ";
        strErr += fullPath;
        strErr += " not exist!";
        TUChar szText[EOS_FILE_MAX_PATH] = { 0 };
        TUString::StrUtf8ToStrUnicode(szText,(Char*)strErr.c_str());
        TApplication::GetCurrentApplication()->MessageBox(szText,NULL,WMB_OK);
        return;
    }

    // clear the zip file path recorded before and record the new path
    memset(s_ZipFilePath, 0, sizeof(char) * EOS_FILE_MAX_PATH);
    strcpy(s_ZipFilePath, fullPath);
}
int main(int argc, char ** argv) {
  ConvertOctomapConfig co_cfg;
  co_cfg.octomap_resolution = 0.1; // was always 0.1 for mav and atlas
  co_cfg.blur_sigma = 0.1; // default was .5
  co_cfg.blur_map = false;
  AppConfig app_cfg;
  
  std::stringstream s;
  s <<  getDataPath() <<   "/octomap.ply" ;
  std::string ply_filename = s.str();
  int input = 0; // 0 = lcm | 1 = file
  
  ConciseArgs opt(argc, (char**)argv);
  //
  opt.add(co_cfg.octomap_resolution, "R", "octomap_resolution","Resolution of underlying octomap");
  opt.add(co_cfg.blur_sigma, "b", "blur_sigma","Radius of the blur kernel");
  opt.add(co_cfg.blur_map, "u", "blur_map","Blur Map");
  //
  opt.add(ply_filename, "f", "ply_filename","Process this PCD file");    
  opt.add(input, "i", "input","Input mode: 0=lcm 1=file 2=republish pcd only");    
  opt.parse();  
  
  std::cout << "Blur sigma: " << co_cfg.blur_sigma << "\n";
  
  boost::shared_ptr<lcm::LCM> lcm(new lcm::LCM);
  if(!lcm->good()){
    std::cerr <<"ERROR: lcm is not good()" <<std::endl;
  }
  
  App* app= new App(lcm, co_cfg, app_cfg);
  
  app->doFileProcessing(ply_filename);

  return 0;
}
Ejemplo n.º 11
0
 void ResourceManager::loadAvatars()
 {
     Texture *tex = graphicsEngine->loadTexture(getDataPath("mia.png"));
     if (!tex)
     {
         logger->logError("Unable to load NPC avatar");
     }
     mAvatars.insert(std::pair<int, Texture*>(0, tex));
 }
Ejemplo n.º 12
0
TEST(RepoClientTest, GetFileTest)
{

	EXPECT_EQ((int)REPOERR_GET_FILE_FAILED, runProcess(produceGetFileArgs(".", "nonExistent1", "nonExistent2")));
	EXPECT_EQ((int)REPOERR_GET_FILE_FAILED, runProcess(produceGetFileArgs(".", REPO_GTEST_DBNAME1, "nonExistent2")));

	EXPECT_EQ((int)REPOERR_OK, runProcess(produceGetFileArgs(".", "sampleDataRW", "cube")));
	EXPECT_TRUE(fileExists(getFileFileName));
	EXPECT_TRUE(filesCompare(getFileFileName, getDataPath("cube.obj")));
}
Ejemplo n.º 13
0
void Prototype01::guiSystemEvent(ofxUIEventArgs &e){
    string name = e.widget->getName();
    
    bool bSamplePalette = false;
    
    if (name == "n clusters"){
        bSamplePalette = true;
    } else if (name.find('.') != string::npos){
        ofxUIToggle *t = (ofxUIToggle*)e.widget;
        if (t != NULL){
            if (t->getValue()){
                img.loadImage(getDataPath()+"images/"+name);
                colorExtractedFbo.allocate(img.getWidth(),img.getHeight());
                bSamplePalette = true;
            }
        }
    }
    
    if(bSamplePalette && img.isAllocated()){
        ofImage smallImg;
        smallImg = img;
        smallImg.resize(img.getWidth()*0.25, img.getHeight()*0.25);
        const int colorCount = nPaletteColors;
        const int sampleCount = smallImg.getHeight() * smallImg.getWidth();
        cv::Mat colorSamples( sampleCount, 1, CV_32FC3 );
        
        // get our pixels
        unsigned char * pixels = smallImg.getPixels();
        
        // clear our list of colors
        palette.clear();
        
        // build our matrix of samples
        cv::MatIterator_<cv::Vec3f> sampleIt = colorSamples.begin<cv::Vec3f>();
        for(int i=0; i<sampleCount; i++){
            int pos = i * 3;
            *sampleIt = cv::Vec3f( pixels[pos], pixels[pos+1], pixels[pos+2] );
            sampleIt++;
        }
        
        // call kmeans
        cv::Mat labels, clusters;
        cv::kmeans( colorSamples, colorCount, labels, cv::TermCriteria(), 2, cv::KMEANS_RANDOM_CENTERS, clusters ); //cv::TermCriteria::COUNT, 8, 0
        
        for( int i = 0; i < colorCount; ++i ){
            ofColor clusterColor = ofColor( clusters.at<cv::Vec3f>(i,0)[0], clusters.at<cv::Vec3f>(i,0)[1], clusters.at<cv::Vec3f>(i,0)[2] );
            palette.push_back(clusterColor);
        }
        
        sortByDistance(palette);
    }
    
    bApplyMedian = true;
}
Ejemplo n.º 14
0
QString Runtime::getCachePath()
{
    static QString cachePath =
#ifdef ANDROID
        // имя пакета хардкодим, пока не найдем как это сделать программно
        QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;").callObjectMethod("getAbsolutePath", "()Ljava/lang/String;").toString() + "/Android/data/org.gkpromtech.monitoring/"
#else
        getDataPath()
#endif
        + "cache/";
    return cachePath;
}
Ejemplo n.º 15
0
void SingleBrush::selfSetup(){
    ofSetCircleResolution(36);
    ofEnableAlphaBlending();
    ofDisableSmoothing();

    ofSetFullscreen(true);
    
    video.initGrabber(640, 480);
    
    colorAddShader.loadFrag(getDataPath()+"shaders/colorAdd.frag");
    noiseShader.loadFrag(getDataPath()+"shaders/noise.frag");
    absorveShader.loadFrag(getDataPath()+"shaders/absorve.frag");
    displaceShader.loadFrag(getDataPath()+"shaders/displace.frag");
    edge.loadFrag(getDataPath()+"shaders/edge.frag");
    
    ofDisableArbTex();
    ofLoadImage(brushTexture, getDataPath()+"brush.png");
    ofEnableArbTex();
    
    int width = ofGetScreenWidth();
    int height = ofGetScreenHeight();
    colorAdded.allocate(width,height);
    water.allocate(width, height,GL_RGB);
    flow.allocate(width, height);
    noise.allocate(width,height);
    canvas.allocate(width, height);
    edgeFbo.allocate(640, 480);
    
    bColorSample = true;
    
    color.set(0);
}
Ejemplo n.º 16
0
void ofx2DPro::setupCoreGuis(){
    setupGui();
    
    logGui.linkDataPath(getDataPath());
    logGui.linkRenderTarget(&getRenderTarget());
    
    guiAdd(logGui);
    
    setupSystemGui();
    setupRenderGui();
    
    backgroundSet(new UIBackground());
}
Ejemplo n.º 17
0
//------------------------------------------------------------------------------
void Config::loadSettings()
{
#ifdef Q_OS_WIN
    QSettings settings("settings.ini", QSettings::IniFormat);
#endif
#ifdef Q_OS_LINUX
    QSettings settings(m_configPath + "/settings.conf", QSettings::NativeFormat);
#endif

    m_appLogLevel = settings.value(QString("log/app")).toInt();
    m_appLang = settings.value(QString("language/lang")).toString();
    if (m_appLang.isEmpty())
        m_appLang = "Russian";

    QDir dir;
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "bible");
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "dictionary");
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "other");
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "book");
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "comments");
    dir.mkpath(getDataPath() + GL_MODULE_PATH + "apocrypha");
    dir.mkpath(getDataPath() + "strongs");
    dir.mkpath(getDataPath() + "plans");

    // viewer settings
    m_viewerColor = qVariantValue<QColor> (settings.value("viewer/color"));
    m_optionChangeTextColor = settings.value("viewer/colorchanging").toBool();

    m_optionAutoChapter = settings.value("viewer/autochapter").toBool();


    // font settings for viewer
    m_fontColor = qVariantValue<QColor> (settings.value("font/color"));
    m_fontSize = settings.value("font/size").toInt();
    m_fontFamily = settings.value("font/family").toString();
    m_fontBold = settings.value("font/bold").toBool();
    m_fontItalic = settings.value("font/italic").toBool();
    m_fontUnderline = settings.value("font/underline").toBool();
    m_fontStrike = settings.value("font/strike").toBool();

    // font settings

    settings.beginGroup("fonts");
    QStringList keys = settings.childKeys();
    foreach (QString key, keys)
    {
        m_GUIMapFont[key] = qVariantValue<QFont> (settings.value(key));
    }
Ejemplo n.º 18
0
OCL_PERF_TEST(Photo, DenoisingColored)
{
    Mat _original = imread(getDataPath("cv/denoising/lena_noised_gaussian_sigma=10.png"));
    ASSERT_FALSE(_original.empty()) << "Could not load input image";

    UMat result(_original.size(), _original.type()), original;
    _original.copyTo(original);

    declare.in(original).out(result).iterations(10);

    OCL_TEST_CYCLE()
            cv::fastNlMeansDenoisingColored(original, result, 10, 10);

    SANITY_CHECK(result, 2);
}
Ejemplo n.º 19
0
void BtsSpawnClient::startClient()
{
	if(isClientReady() || (p->clientProc && p->clientProc->state() == QProcess::Starting))
		return;

	QJsonObject configObject;
	configObject.insert("storage_path", getDataPath());
	configObject.insert("use_gui", false);

	QJsonObject webuiObject;
	webuiObject.insert("listen", QString("%1:%2").arg(p->host).arg(p->port));
	webuiObject.insert("login", p->username);
	webuiObject.insert("password", p->password);
	webuiObject.insert("api_key", BtsGlobal::getApiKey().toString());

	configObject.insert("webui", webuiObject);

	p->configFile.open();
	QJsonDocument saveDoc(configObject);
	p->configFile.write(saveDoc.toJson());
	p->configFile.close();

	p->configFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);

	p->cur_port = p->port;
	p->cur_password = p->password;
	p->cur_username = p->username;

	p->clientProc = new QProcess(this);
	connect(p->clientProc, SIGNAL(finished(int)), this, SLOT(procFinished(int)));
	connect(p->clientProc, SIGNAL(finished(int)), p->clientProc, SLOT(deleteLater()));
	connect(p->clientProc, SIGNAL(started()), this, SLOT(procStarted()));

#ifdef Q_OS_WIN
# define ARG_PREFIX "/"
#else
# define ARG_PREFIX "--"
#endif

	p->clientProc->setProgram(BtsGlobal::getBtsyncExecutablePath());
	p->clientProc->setArguments(QStringList()
	                            << ARG_PREFIX "nodaemon"
	                            << ARG_PREFIX "config" << p->configFile.fileName());

	p->clientProc->setProcessChannelMode(QProcess::ForwardedChannels);

	p->clientProc->start();
}
Ejemplo n.º 20
0
void ofx2DPro::guiSave(string presetName){
    
    cout << "Saving " << presetName << endl;    
    
    ofDirectory dir;
    string presetDirectory = getDataPath()+"Presets/"+presetName+"/";
    if(!dir.doesDirectoryExist(presetDirectory)){
        dir.createDirectory(presetDirectory);
        presetRadio->addToggle(gui->addToggle(presetName, true));
        gui->autoSizeToFitWidgets();
    }
    
    for(int i = 0; i < guis.size(); i++){
        guis[i]->saveSettings(presetDirectory+guis[i]->getName()+".xml");
    }
}
Ejemplo n.º 21
0
	IDataStream* MyDataManager::getData(const std::string& _name) {
		std::string filepath = getDataPath(_name);
		if (filepath.empty()) {
			return nullptr;
		}

		std::ifstream* stream = new std::ifstream();
		stream->open(filepath.c_str(), std::ios_base::binary);
		if (!stream->is_open()) {
			delete stream;
			return nullptr;
		}

		DataFileStream* data = new DataFileStream(stream);
		return data;
	}
Ejemplo n.º 22
0
TEST(ElectronPairProduction, valuesCMB) {
    // Test if energy loss corresponds to the data table.
    std::vector<double> x;
    std::vector<double> y;
    std::ifstream infile(getDataPath("pair_CMB.txt").c_str());
    while (infile.good()) {
        if (infile.peek() != '#') {
            double a, b;
            infile >> a >> b;
            if (infile) {
                x.push_back(a * eV);
                y.push_back(b * eV / Mpc);
            }
        }
        infile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
Ejemplo n.º 23
0
StoragePtr InterpreterSystemQuery::tryRestartReplica(const String & database_name, const String & table_name, Context & context)
{
    auto database = context.getDatabase(database_name);
    auto table_ddl_guard = context.getDDLGuard(database_name, table_name, "Table " + database_name + "." + table_name + " is restarting right now");
    ASTPtr create_ast;

    /// Detach actions
    {
        auto table = context.tryGetTable(database_name, table_name);

        if (!table || !dynamic_cast<const StorageReplicatedMergeTree *>(table.get()))
            return nullptr;

        table->shutdown();

        /// If table was already dropped by anyone, an exception will be thrown
        auto table_lock = table->lockForAlter(__PRETTY_FUNCTION__);
        create_ast = context.getCreateTableQuery(database_name, table_name);

        database->detachTable(table_name);
    }

    /// Attach actions
    {
        /// getCreateTableQuery must return canonical CREATE query representation, there are no need for AST postprocessing
        auto & create = typeid_cast<ASTCreateQuery &>(*create_ast);
        create.attach = true;

        std::string data_path = database->getDataPath();
        auto columns = InterpreterCreateQuery::getColumnsDescription(*create.columns, context);

        StoragePtr table = StorageFactory::instance().get(create,
            data_path,
            table_name,
            database_name,
            context,
            context.getGlobalContext(),
            columns,
            create.attach,
            false);

        database->createTable(context, table_name, table, create_ast);

        table->startup();
        return table;
    }
}
Ejemplo n.º 24
0
OCL_PERF_TEST(HOGFixture, HOG)
{
    UMat src;
    imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE).copyTo(src);
    ASSERT_FALSE(src.empty());

    vector<cv::Rect> found_locations;
    declare.in(src);

    HOGDescriptor hog;
    hog.setSVMDetector(hog.getDefaultPeopleDetector());

    OCL_TEST_CYCLE() hog.detectMultiScale(src, found_locations);

    std::sort(found_locations.begin(), found_locations.end(), RectLess());
    SANITY_CHECK(found_locations, 3);
}
Ejemplo n.º 25
0
// This method is trying to find out where are the DAT files located
std::string CrossPlatform::findFalloutDataPath()
{
    if (_falloutDataPath.length() > 0)
        return _falloutDataPath;
    Logger::info() << "Looking for Fallout data files" << std::endl;
    std::vector<std::string> directories;
    directories.push_back(getCurrentDirectory());
    directories.push_back(getDataPath());

    try
    {
        std::vector<std::string> cdDrives = getCdDrivePaths();
        directories.insert(directories.end(), cdDrives.begin(), cdDrives.end());
    }
    catch (Exception e)
    {
        Logger::error() << e.message() << std::endl;
    }

    for (auto &directory : directories)
    {
        if (std::all_of(
                necessaryDatFiles.begin(),
                necessaryDatFiles.end(),
                [directory](std::string file) {
                    std::ifstream stream(directory + "/" + file);
                    if (stream)
                    {
                        Logger::info() << "Searching in directory: " << directory << " " << file << " [FOUND]" << std::endl;
                        return true;
                    }
                    else
                    {
                        Logger::info() << "Searching in directory: " << directory << " " << file << " [NOT FOUND]" << std::endl;
                        return false;
                    }
                })
                )
        {
            _falloutDataPath = directory;
            return _falloutDataPath;
        }
    }

    throw Exception("Fallout data files are not found!");
}
Ejemplo n.º 26
0
TEST(RepoClientTest, CreateFedTest)
{
	//this ensures we can run processes
	ASSERT_TRUE(system(nullptr));

	//Test failing to connect to database
	std::string db = "stFed";
	std::string failToConnect = produceCreateFedArgs("whatever", "", "invalidAdd", 12345);
	EXPECT_EQ((int)REPOERR_AUTH_FAILED, runProcess(failToConnect));

	//Test Bad authentication
	std::string failToAuth = produceCreateFedArgs("whatever", "", REPO_GTEST_DBADDRESS, REPO_GTEST_DBPORT, "badUser", "invalidPasswrd2");
	EXPECT_EQ((int)REPOERR_AUTH_FAILED, runProcess(failToAuth));

	//Test Bad FilePath
	std::string badFilePath = produceCreateFedArgs("nonExistentFile.json");
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(badFilePath));

	//Test Completely empty file
	std::string emptyFilePath = produceCreateFedArgs(getDataPath(emptyFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(emptyFilePath));

	//Test json file with {}
	std::string empty2FilePath = produceCreateFedArgs(getDataPath(emptyJSONFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(empty2FilePath));

	//Test json file with no sub projects
	std::string noSPFilePath = produceCreateFedArgs(getDataPath(noSubProjectJSONFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(noSPFilePath));
	EXPECT_FALSE(projectExists(genFedDB, genFedNoSubProName));

	//Test json file with empty string as database name
	std::string noDBFilePath = produceCreateFedArgs(getDataPath(noDbNameJSONFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(noDBFilePath));

	//Test json file with empty string as project name
	std::string noProFilePath = produceCreateFedArgs(getDataPath(noProNameJSONFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(noProFilePath));

	//Test badly formatted JSON file
	std::string invalidJSONFilePath = produceCreateFedArgs(getDataPath(invalidJSONFile));
	EXPECT_EQ((int)REPOERR_FED_GEN_FAIL, runProcess(invalidJSONFilePath));

	//Test success
	std::string goodFilePath = produceCreateFedArgs(getDataPath(validGenFedJSONFile));
	EXPECT_EQ((int)REPOERR_OK, runProcess(goodFilePath));
	EXPECT_TRUE(projectExists(genFedDB, genFedSuccessName));
}
Ejemplo n.º 27
0
vector<string> ofx2DPro::getPresets(){
	vector<string> presets;
	string presetPath = getDataPath()+"Presets/";
	ofDirectory presetsFolder = ofDirectory(presetPath);
    
	if(presetsFolder.exists()){
		presetsFolder.listDir();
		for(int i = 0; i < presetsFolder.size(); i++){
			if(presetsFolder.getFile(i).isDirectory() &&
               ofFilePath::removeTrailingSlash(presetsFolder.getName(i)) != "Working" &&
			   presetsFolder.getName(i).at(0) != '_') //use leading _ to hide folders
            {
				presets.push_back(presetsFolder.getName(i));
			}
		}
	}
	return presets;
}
Ejemplo n.º 28
0
INT_PTR CMimAPI::foldersPathChanged()
{
	TCHAR szTemp[MAX_PATH + 2] = {'\0'};

	if(m_hDataPath) {
		FoldersGetCustomPathT(m_hDataPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getDataPath()));
		mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%s"), szTemp);

		FoldersGetCustomPathT(m_hSkinsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSkinPath()));
		mir_sntprintf(m_szSkinsPath, MAX_PATH - 1, _T("%s"), szTemp);

		/*
		 * make sure skins root path always ends with a '\' - this is assumed by the skin
		 * selection code.
		 */

		Utils::ensureTralingBackslash(m_szSkinsPath);

		FoldersGetCustomPathT(m_hAvatarsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSavedAvatarPath()));
		mir_sntprintf(m_szSavedAvatarsPath, MAX_PATH, _T("%s"), szTemp);

		FoldersGetCustomPathT(m_hChatLogsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getChatLogPath()));
		mir_sntprintf(m_szChatLogsPath, MAX_PATH, _T("%s"), szTemp);

		Utils::ensureTralingBackslash(m_szChatLogsPath);
	}
	CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szProfilePath);
	CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szSkinsPath);
	CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szSavedAvatarsPath);
	CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)m_szChatLogsPath);

#if defined(_FOLDER_LOCKING)
	mir_sntprintf(szTemp, MAX_PATH, L"%sfolder.lck", m_szChatLogsPath);

	if(m_hChatLogLock != INVALID_HANDLE_VALUE)
		CloseHandle(m_hChatLogLock);

	m_hChatLogLock = CreateFile(szTemp, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_HIDDEN, 0);
#endif

	Skin->extractSkinsAndLogo(true);
	Skin->setupAeroSkins();
	return 0;
}
void InBoxes::guiSystemEvent(ofxUIEventArgs &e){
    string name = e.widget->getName();
    
    if (name == "DEBUG"){
        if (bDebug){
            camera.disableMouseInput();
            timeline->stop();
            bPlaying = false;
        } else {
            
            //  Clean final destinations
            //
            for (int i = 0; i < publicBooks.size(); i++) {
                publicBooks[i].destiny = ofPoint(0,0,0);
            }
            
            for(int i = 0; i < categories.size(); i++){
                
                //  Save settings
                //
                categories[i].saveSettings(getDataPath()+ofToString(i)+".xml");
                
                //  Re-assign final destinations
                //
                vector<ofPoint> positions;
                categories[i].getPoints(positions);
                for(int j = 0; j < positions.size(); j++ ){
                    
                    bool foundDestiny = true;
                    while ( foundDestiny ) {
                        int index = ofRandom( publicBooks.size() );
                        
                        if ( publicBooks[index].destiny == ofPoint(0,0,0) ){
                            publicBooks[index].destiny = positions[j];
                            foundDestiny = false;
                        }
                    }
                }
            }
            camera.enableMouseInput();
        }
    }
}
Ejemplo n.º 30
0
void Prototype01::selfSetupSystemGui(){
    sysGui->addSlider("median radius", 0.1, 2.5, &medianFilter.radius);
    sysGui->addSlider("n clusters", 1, 20, &nPaletteColors);
    
    vector<string> backgroundsList;
    string path = getDataPath()+"images";
    ofDirectory backgroundsDir(path);
    if(backgroundsDir.exists()){
		backgroundsDir.listDir();
        int total = backgroundsDir.getFiles().size();
        for (int i = 0; i < total; i++) {
            backgroundsList.push_back( backgroundsDir.getName(i) );
        }
        
        if(images == NULL){
            images = sysGui->addRadio("Images", backgroundsList);
        }
    }
}