Пример #1
0
FontCache::FontCache(FontMgr& manager, const std::string& monospacePath, const std::string& proportionalPath) :
    fontManager_(manager),
    monospacePath(monospacePath),
    proportionalPath(proportionalPath)
{
    // Check that the typeface files are actually there. If they do not exist,
    // libfreetype will cause a crash and provide little information on what is wrong.
    checkFileExists(monospacePath);
    checkFileExists(proportionalPath);
}
Пример #2
0
bool Handshake::doSanityCheck( const char* RFACTOR_PATH, const char* PLUGIN_PATH, char* fileBuffer )
{
    logg( "Doing a sanity check..." );
    
    bool warningsDetected = false;
    
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\log", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: log directory not found. Using rFactor root folder." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD", fileBuffer ), false ) == 0 )
    {
        logg( "    ERROR: rfDynHud directory not found in the rFactor Plugins folder. The plugin won't work." );
        return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\rfdynhud.jar", fileBuffer ), false ) == 0 )
    {
        logg( "    ERROR: rfdynhud.jar not found in the rFactor Plugins\\rfDynHUD folder. The plugin won't work." );
        return ( false );
    }
    
    //readIniString( ini_filename, "GENERAL", "numArchivedLogFiles", "5", buffer, 16 );
    if ( checkDirectoryExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: config directory not found in the rFactor Plugins\\rfDynHUD folder. Fallback config will be used.\r\nUse the editor to create a valid config and store it as overlay.ini in the config folder. Please see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config\\overlay.ini", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: overlay.ini configuration file not found in the rFactor Plugins\\rfDynHUD\\config folder. If no mod specific configurations are stored (which is not checked here), fallback config will be used.\r\nUse the editor to create a valid config and store it as overlay.ini in the config folder. Please see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( checkFileExists( getFullPath2( RFACTOR_PATH, "Plugins\\rfDynHUD\\config\\three_letter_codes.ini", fileBuffer ), false ) == 0 )
    {
        logg( "    WARNING: three_letter_codes.ini file not found in the rFactor Plugins\\rfDynHUD\\config folder. Driver names will be displayed in full length regardless of the configuration.\r\nPlease see the readme.txt in the config folder for more info." );
        warningsDetected = true;
        //return ( false );
    }
    
    if ( warningsDetected )
        logg( "Sanity check passed, but warnings detected. The plugin may not work as expected." );
    else
        logg( "Sanity check passed." );
    
    return ( true );
}
Пример #3
0
bool SlotAssetsMgr::checkZipMd5(int machineId){
    char mid[10];
    sprintf(mid, "%d", machineId);
    string zipDir = getMachineZipDir().append(mid).append("/");
    string xmlPath = zipDir + "res.xml";
    if(!checkFileExists(xmlPath)) {
        CCLOG("[assets] res xml not exist: %s", xmlPath.c_str());
        return false;
    }
    
    ResourceConfigCache configCache;
    configCache.parse(xmlPath, zipDir);
    
    const map<ImageId, RImageConfig>& imageConfig = configCache.getImagesConfig();
    for(map<ImageId, RImageConfig>::const_iterator iter = imageConfig.begin(); iter != imageConfig.end(); iter++) {
        string imageFilePath = iter->second.getImageId();
        string imageMd5 = iter->second.getMd5Hexdigest();
        if(!iter->second.isInPlist() && !checkFileExists(imageFilePath)) {
            CCLOG("[assets] zip image file not exist, %s", imageFilePath.data());
            return false;
        }
        
        int startTime = Global::getLocalTime();
        string localImageMd5 = CMD5Checksum::GetMD5(imageFilePath);
        int endTime = Global::getLocalTime();
        if(endTime - startTime >= 3) {
            CCLOG("[warning] parse md5 time %d, path: %s", endTime - startTime, imageFilePath.data());
        }
        if(imageMd5 != localImageMd5) {
            CCLOG("[assets] zip image md5 not same, server: %s, local: %s", imageFilePath.data(),localImageMd5.data());
            return false;
        }
    }
    
    const map<VideoId, RVideoConfig>& vedioConfig = configCache.getVideosConfig();
    for(map<VideoId, RVideoConfig>::const_iterator iter = vedioConfig.begin(); iter != vedioConfig.end(); iter++) {
        string vedioFilePath = iter->second.getVideoId();
        string vedioMd5 = iter->second.getMd5Hexdigest();
        if(!checkFileExists(vedioFilePath)) {
            CCLOG("[assets] zip vedio file not exist, %s", vedioFilePath.data());
            return false;
        }
        
        string localVedioMd5 = CMD5Checksum::GetMD5(vedioFilePath);
        if(vedioMd5 != localVedioMd5) {
            CCLOG("[assets] zip vedio md5 not same, server: %s, local: %s", vedioMd5.data(),localVedioMd5.data());
            return false;
        }
    }
    
    
    return true;
}
Пример #4
0
QString QBattSysFSMethod::getPSUTechnology()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_TECHNOLOGY))
		return getFileContents(psu->battery.path, FILE_BATT_TECHNOLOGY);

	return RESPONSE_N_A;
}
Пример #5
0
QString QBattSysFSMethod::getPSUStatus()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_STATUS))
		return getFileContents(psu->battery.path, FILE_BATT_STATUS);

	return RESPONSE_N_A;
}
Пример #6
0
QString QBattSysFSMethod::getACADName()
{
	if (checkFileExists(psu->ac_adapter.path, PSU_FILE_TYPE))
		return getFileContents(psu->ac_adapter.path, PSU_FILE_TYPE);

	return RESPONSE_N_A;
}
Пример #7
0
void CFileSpraySoapBindingEx::xsltTransform(const char* xml, const char* sheet, IProperties *params, StringBuffer& ret)
{
    StringBuffer xsl;
    if (!checkFileExists(sheet))
        throw MakeStringException(ECLWATCH_FILE_NOT_EXIST, "Cannot open stylesheet %s",sheet);

    Owned<IXslProcessor> proc  = getXslProcessor();
    Owned<IXslTransform> trans = proc->createXslTransform();

    trans->setXmlSource(xml, strlen(xml));
    trans->loadXslFromFile(sheet);

    if (params)
    {
        Owned<IPropertyIterator> it = params->getIterator();
        for (it->first(); it->isValid(); it->next())
        {
            const char *key = it->getPropKey();
            //set parameter in the XSL transform skipping over the @ prefix, if any
            const char* paramName = *key == '@' ? key+1 : key;
            trans->setParameter(paramName, StringBuffer().append('\'').append(params->queryProp(key)).append('\'').str());
        }
    }

    trans->transform(ret);
}
Пример #8
0
void mtsPIDQtWidget::EnableLog(bool localButtonUsed, bool enable)
{
    logsEnabled = enable;
    if(logsEnabled)
    {
        //CMN_LOG_RUN_WARNING << "mtsPIDQtWidget: logs enabled" << std::endl;

        // UBC open output file
        if(!effortLogFile.is_open())
        {
            std::string fname = component_name;
            fname.append("PIDWidgetJointEffort.log");
            checkFileExists(&fname);
            effortLogFile.open(fname.c_str(), std::ofstream::out | std::ofstream::app);
            if(!effortLogFile.is_open())
                CMN_LOG_CLASS_RUN_ERROR << "Failed to open the log file!" << std::endl;
        }

        if(effortLogFile.is_open())
            effortLogFile << "*********Log number:   " << logEntryIndex << std::endl;
    }
    else {
        closeLogs(false);
        //CMN_LOG_RUN_WARNING << "mtsPIDQtWidget: logs disabled" << std::endl;
    }

    PID.EnableLogs(logsEnabled);

    if(!localButtonUsed) {
        QCBEnableLOG->setChecked(enable);
    }
}
Пример #9
0
QString QBattSysFSMethod::getPSUType()
{
	if (checkFileExists(psu->battery.path, PSU_FILE_TYPE))
		return getFileContents(psu->battery.path, PSU_FILE_TYPE);

	return RESPONSE_N_A;
}
bool Resources::fileExists(const string &path, InstanceID instanceId, const shared_ptr<Query>& query)
{
    LOG4CXX_TRACE(logger, "Resources::fileExists. Checking file '" << path << "'");
    NetworkManager* networkManager = NetworkManager::getInstance();

    if (instanceId == query->getInstanceID())
    {
        LOG4CXX_TRACE(logger, "Resources::fileExists. Instance id " << instanceId << " is local instance. Returning result.");
        return checkFileExists(path);
    }
    else
    {
        LOG4CXX_TRACE(logger, "Resources::fileExists. Instance id " << instanceId << " is remote instance. Requesting result.");
        FileExistsResourcesCollector* collector = new FileExistsResourcesCollector();
        uint64_t id = 0;
        {
            ScopedMutexLock lock(_lock);
            id = ++_lastResourceCollectorId;
            _resourcesCollectors[id] = collector;
        }

        shared_ptr<MessageDesc> msg = make_shared<MessageDesc>(mtResourcesFileExistsRequest);
        shared_ptr<scidb_msg::ResourcesFileExistsRequest> request =
            msg->getRecord<scidb_msg::ResourcesFileExistsRequest>();
        msg->setQueryID(0);
        request->set_resource_request_id(id);
        request->set_file_path(path);
        networkManager->sendMessage(instanceId, msg);

        LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting while instance return result for collector " << id);

        try
        {
           Semaphore::ErrorChecker errorChecker = bind(&Query::validateQueryPtr, query);
           collector->_collectorSem.enter(1, errorChecker);
        }
        catch (...)
        {
            LOG4CXX_TRACE(logger, "Resources::fileExists. Waiting for result of collector " << id <<
                " interrupter by error");
            {
                ScopedMutexLock lock(_lock);
                delete _resourcesCollectors[id];
                _resourcesCollectors.erase(id);
            }
            throw;
        }

        LOG4CXX_TRACE(logger, "Resources::fileExists. Returning result of collector " << id);

        bool result;
        {
            ScopedMutexLock lock(_lock);
            result = ((FileExistsResourcesCollector*) _resourcesCollectors[id])->_instancesMap[instanceId];
            delete _resourcesCollectors[id];
            _resourcesCollectors.erase(id);
        }
        return result;
    }
}
int main(int argc, char *argv[]) {
  char inputSequenceFile[100], log_desc[1000] ;
  int ret ;

  if(argc != 2) {
    printf("Usage: %s <input-transaction-file-path>\n", argv[0]) ;
    return  0 ;
  }
  strcpy(inputSequenceFile, argv[1]) ;
  ret = checkFileExists(inputSequenceFile) ;
  if(ret == -1) {
   printf("main: File %s does not exist or is an empty file. Exiting\n", inputSequenceFile) ;
   return  0 ;
  }
  FILE *fp = fopen("repcrec.log", "w") ;
  if(fp == NULL) {
    printf("main: failed to open log file in write mode. Error: %s\n", (char *)strerror(errno)) ;
  }
  else {
    fclose(fp) ;
  }
  initializeTransactionManager() ;
  initializeSiteData() ;
  ret = parseInput(inputSequenceFile) ;
  if(ret == -1) {
   printf("main: parseInput could not parse file %s. Exiting\n", inputSequenceFile) ;
   return  0 ;
  }
  startTransactionManager() ;
  sprintf(log_desc, "main: Transaction Manager exiting\n") ;
  logString(log_desc) ;
  return  0 ;
}
Пример #12
0
QString QBattSysFSMethod::getPSUSerialNumber()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_SERIAL_NUMBER))
		return getFileContents(psu->battery.path, FILE_BATT_MANUFACTURER);

	return RESPONSE_N_A;
}
Пример #13
0
int profileManager(int choice){
	int fileFlag,option;
	FILE *pProfiles;
	fileFlag=checkFileExists("profiles.txt");
	switch(choice){
		case 1:
			if(fileFlag){
				pProfiles=fopen("profiles.txt","r");
				printProfiles(pProfiles);
				option = getChoice();
				if(tolower(option) == 'n'){	
					addProfile();
				}else if(tolower(option) == 'q'){
					fclose(pProfiles);
					return 0;
				}else if(tolower(option) == 'd'){
					
				}else{

				}

				fclose(pProfiles);
				return option-'0';
			}else{
				return makeProfileFile();

			}
		case 2:
			if(fileFlag){
				
			}else{

			}
	}
}
Пример #14
0
QString QBattSysFSMethod::getPSUModelName()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_MODEL_NAME))
		return getFileContents(psu->battery.path, FILE_BATT_MODEL_NAME);

	return RESPONSE_N_A;
}
Пример #15
0
QString QBattSysFSMethod::getPSUManufacturer()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_MANUFACTURER))
		return getFileContents(psu->battery.path, FILE_BATT_MANUFACTURER);

	return RESPONSE_N_A;
}
Пример #16
0
static void splitGitFileName(const char *fullName, StringAttr &gitDir, StringAttr &revision, StringAttr &relPath)
{
    assertex(fullName);
    const char *git = strstr(fullName, ".git" PATHSEPSTR "{" );
    assertex(git);
    const char *tail = git+5;
    gitDir.set(fullName, tail-fullName);
    assertex (*tail=='{');
    tail++;
    const char *end = strchr(tail, '}');
    if (!end)
        throw MakeStringException(0, "Invalid git repository filename - no matching } found");
    revision.set(tail, end - tail);
    tail = end+1;
    if (*tail==PATHSEPCHAR)
        tail++;
    else if (*tail != 0)
        throw MakeStringException(0, "Invalid git repository filename - " PATHSEPSTR " expected after }");
    if (tail && *tail)
    {
        StringBuffer s(tail);
        s.replace(PATHSEPCHAR, '/');
        relPath.set(s);
    }
    else
        relPath.clear();
    // Check it's a valid git repository
    StringBuffer configName(gitDir);
    configName.append("config");
    if (!checkFileExists(configName.str()))
        throw MakeStringException(0, "Invalid git repository - config file %s not found", configName.str());
}
Пример #17
0
QString QBattSysFSMethod::getPSUCapacityLevel()
{
	if (checkFileExists(psu->battery.path, FILE_BATT_CAPACITY_LEVEL))
		return getFileContents(psu->battery.path, FILE_BATT_CAPACITY_LEVEL);

	return RESPONSE_N_A;
}
Пример #18
0
int QBattSysFSMethod::getPSUCurrentNow()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_CURRENT_NOW))
		ret = getFileContents(psu->battery.path, FILE_BATT_CURRENT_NOW).toInt();

	return ret;
}
Пример #19
0
int QBattSysFSMethod::getACADOnline()
{
	int ret = -1;

	if (checkFileExists(psu->ac_adapter.path, FILE_ACAD_ONLINE))
		ret = getFileContents(psu->ac_adapter.path, FILE_ACAD_ONLINE).toInt();

	return ret;
}
Пример #20
0
int QBattSysFSMethod::getPSUPowerNow()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_POWER_NOW))
		ret = getFileContents(psu->battery.path, FILE_BATT_POWER_NOW).toInt();

	return ret;
}
Пример #21
0
int QBattSysFSMethod::getPSUEnergyFullDesign()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_ENERGY_FULL_DESIGN))
		ret = getFileContents(psu->battery.path, FILE_BATT_ENERGY_FULL_DESIGN).toInt();

	return ret;
}
Пример #22
0
int QBattSysFSMethod::getPSUPresent()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_PRESENT))
		ret = getFileContents(psu->battery.path, FILE_BATT_PRESENT).toInt();

	return ret;
}
Пример #23
0
int QBattSysFSMethod::getPSUChargeFull()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_CHARGE_FULL))
		ret = getFileContents(psu->battery.path, FILE_BATT_CHARGE_FULL).toInt();

	return ret;
}
Пример #24
0
int QBattSysFSMethod::getPSUVoltageNow()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_VOLTAGE_NOW))
		ret = getFileContents(psu->battery.path, FILE_BATT_VOLTAGE_NOW).toInt();

	return ret;
}
Пример #25
0
int QBattSysFSMethod::getPSUVoltageMinDesign()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_VOLTAGE_MIN_DESIGN))
		ret = getFileContents(psu->battery.path, FILE_BATT_VOLTAGE_MIN_DESIGN).toInt();

	return ret;
}
Пример #26
0
int QBattSysFSMethod::getPSUCycleCount()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_CYCLE_COUNT))
		ret = getFileContents(psu->battery.path, FILE_BATT_CYCLE_COUNT).toInt();

	return ret;
}
Пример #27
0
int QBattSysFSMethod::getPSUCapacity()
{
	int ret = -1;

	if (checkFileExists(psu->battery.path, FILE_BATT_CAPACITY))
		ret = getFileContents(psu->battery.path, FILE_BATT_CAPACITY).toInt();

	return ret;
}
Пример #28
0
void extern readPhenoFile(vector<Individual*>& sample, vector<Locus*>& locus, vector<CSNP*>& snp)
{
  par.qt = false;
  par.bt = true;
  
  checkFileExists(par.phenofile);


  ifstream PHE(par.phenofile.c_str(), ios::in);
  
  map<string, Individual*> uid;
  map<string, Individual*>::iterator ii;
  
  for(int i=0; i<sample.size(); i++)
    {
      uid.insert(make_pair(sample[i]->fid+"_"+sample[i]->iid, sample[i]));
      sample[i]->phenotype = -9;
      sample[i]->phenotypes.resize(0);
      sample[i]->missing = true;
    }
  
  vector<int> pheno_idx;
  pheno_idx.resize(0);
  if(par.pheno_names.size()>0)
    {
      string pfid, piid, ph;
      char cline[par.MAX_LINE_LENGTH];
      PHE.getline(cline, par.MAX_LINE_LENGTH, '\n');
      string sline = cline;
      if(sline!="")
	{
	  string buf;
	  stringstream ss(sline);
	  vector<string> tokens;
	  while(ss>>buf)
	    tokens.push_back(buf);

	  if(tokens[0] != "FID")
	    error("First header field must be FID");
	  if(tokens[1] != "IID")
	    error("Second header field must be IID");
	  
	  for(int j=0; j<par.pheno_names.size(); j++)
	    for(int i=2; i<tokens.size(); i++)
	      if(tokens[i] == par.pheno_names[j])
		{
		  pheno_idx.push_back(i-1);
		
		}

	  if(pheno_idx.size()<par.pheno_names.size())
	    error("Did not find phenotypes");

	  
	} // end of if sline != ""
Пример #29
0
eclObjParameterType EclObjectParameter::set(const char *param)
{
    value.set(param);
    if (streq(param, "stdin"))
        loadStdIn();
    else if (checkFileExists(param))
        loadFile();
    else if (looksLikeOnlyAWuid(param))
        type = eclObjWuid;
    return type;
}
Пример #30
0
static void xsltTransform(const char* xml, const char* sheet, IProperties *params, StringBuffer& ret)
{
    if(!checkFileExists(sheet))
        throw MakeStringException(-1, "Could not find stylesheet %s.",sheet);
    Owned<IXslProcessor> proc = getXslProcessor();
    Owned<IXslTransform> trans = proc->createXslTransform();
    trans->setXmlSource(xml, strlen(xml));
    trans->loadXslFromFile(sheet);
    trans->copyParameters(params);
    trans->transform(ret);
}