コード例 #1
0
void ManageCrossPlayerData::loadCrossPlayerData()
{
	boost::filesystem::path path(CROSS_PLAYER_PATH);

	vector<string> platform_vec;
	vector<string> line_id_vec;
	vector<string> player_vec;
	
	searchDir(CROSS_PLAYER_PATH, platform_vec);
	for (vector<string>::iterator it = platform_vec.begin(); it != platform_vec.end(); ++it)
	{
		string platform_path = CROSS_PLAYER_PATH;
		platform_path += *it;
		line_id_vec.clear();
		searchDir(platform_path, line_id_vec);
		string line_path = platform_path + "/";
		for (vector<string>::iterator sub_it = line_id_vec.begin(); sub_it != line_id_vec.end(); ++sub_it)
		{
			line_path += *sub_it + "/";
			player_vec.clear();
			searchDir(line_path, player_vec);
			for (vector<string>::iterator player_it = player_vec.begin(); player_it != player_vec.end(); ++player_it)
			{
				string player_path = line_path + *player_it;
				loadCrossPlayerData(*it, *sub_it, player_path);
			}
		}
	}
}
コード例 #2
0
ファイル: qbattsysfsmethod.cpp プロジェクト: gerbert/qbatt
bool QBattSysFSMethod::searchSysFs_Battery()
{
	QDir searchDir(PSU_SYSTEM_PATH);
	QString path;

	if (!checkDirExists(PSU_SYSTEM_PATH))
		return false;

	searchDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
	QDirIterator qdi(searchDir, QDirIterator::Subdirectories);

	while (qdi.hasNext()) {
		path = qdi.next();
		if (!(QString::compare(getFileContents(path, PSU_FILE_TYPE),
							   DEF_BATTERY_TYPE, Qt::CaseSensitive))) {
			psu->battery.path = path;
			return true;
		}
	}

	// Initialize path with "none"
	psu->battery.path = PSU_SYSTEM_PATH_NONE;

	return false;
}
コード例 #3
0
ファイル: fat32.c プロジェクト: kristenmills/Efcs
/*---------------------------------------------------------------------------
  Opens a case sensitive file 8.3 file name.
   int32_t fatOpen(const char *fileName, FileHandle *handle)
  Where:
   char *fileName     - Pointer to the case specific name
   FileHandle *handle - Pointer to file handle storage block
  Returns 1 for success, 0 for failure
---------------------------------------------------------------------------*/
uint32_t fatOpen(const char *fileName, FileHandle *handle)
{
    uint32_t i = 0;
    uint32_t j = 0;
    uint32_t k =8;
    uint8_t extension = 0;
    //Gets the file name in the right format
    while(fileName[i]) {
        if(fileName[i] == '.'){
            extension = i;
        }
        if(i < SHORT_NAME_LEN){
            handle->fileName[i] = fileName[i];
        }
        i++;
    }

    for(j = extension; j < SHORT_NAME_LEN; j++){
        handle->fileName[j] = ' ';
    }
    for(j = extension + 1; j < i; j++){
        handle->fileName[k] = fileName[j];
        k++;
    }
    //Search the directory for the file and populates the file handle
    FAT_DirEntry * d = searchDir(handle->fileName);
    if(d){
        handle->FileSize = d->FileSize;
        handle->Attr = d->Attr;
        handle->startingCluster = (d->FstClusHI << 16) | d->FstClusLO;
        return 1;
    }
    return 0;
} // End fatOpen
コード例 #4
0
ファイル: Worker.cpp プロジェクト: Nanolx/lumina
void Worker::beginsearch(){
  stopsearch = false; //just starting search - always set this to false initially
  emit SearchUpdate( QString(tr("Starting Search: %1")).arg(sterm) );
  //Now Perform the search
  if(sapp){
    //First try to match based on the name
    QStringList tmp = applist.filter(":::1:::"+sterm, Qt::CaseInsensitive);
    tmp.sort();
    for(int i=0; i<tmp.length(); i++){
      if(stopsearch){ return; }
      emit FoundItem( tmp[i].section(":::4:::",1,1) );
    }
    //Check if this is a binary name
    if(stopsearch){ return; }
    if(LUtils::isValidBinary(sterm)){
      emit FoundItem(sterm);
      return;
    }
    //If items found, go ahead and stop now
    if(stopsearch){ return; }
    if(tmp.length()<1){
      //Now try to match based on the generic name
      tmp = applist.filter(":::2:::"+sterm, Qt::CaseInsensitive);
      tmp.sort();
      for(int i=0; i<tmp.length(); i++){
        if(stopsearch){ return; }
        emit FoundItem( tmp[i].section(":::4:::",1,1) );
      }
    }
    //If items found, go ahead and stop now
    if(stopsearch){ return; }
    if(tmp.length()<1){
      //Now try to match based on anything (name/genericname/comment)
      tmp = applist.filter(sterm, Qt::CaseInsensitive);
      tmp.sort();
      for(int i=0; i<tmp.length(); i++){
        if(stopsearch){ return; }
        emit FoundItem( tmp[i].section(":::4:::",1,1) );
      }
    }
    
  }else{
    //Search through the user's home directory and look for a file/dir starting with that term
    if(!sterm.contains("*")){
      sterm.prepend("*"); sterm.append("*"); //make sure it is a search glob pattern
    }
    if(startDir.isEmpty()){ startDir = QDir::homePath(); }
    searchDir(startDir);
    
  }
  emit SearchUpdate( tr("Search Finished") );
  emit SearchDone();
}
コード例 #5
0
ファイル: Worker.cpp プロジェクト: Nanolx/lumina
bool Worker::searchDir(QString dirpath){
  //This is a recursive search algorithm for scanning a directory
  QDir dir(dirpath);
  //First look for files that match the search term	
  if(stopsearch){ return true; }
  emit SearchUpdate( QString(tr("Searching: %1")).arg(dirpath.replace(QDir::homePath(),"~")) );
  QStringList tmp;
  if(sterm.startsWith(".")){ tmp = dir.entryList(QStringList(sterm), QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden, QDir::Name); }
  else{ tmp = dir.entryList(QStringList(sterm), QDir::AllEntries | QDir::NoDotAndDotDot , QDir::Name); }
  for(int i=0; i<tmp.length(); i++){
    if(stopsearch){ return true; }
    emit FoundItem( dir.absoluteFilePath(tmp[i]) );
  }
  if(stopsearch){ return true; }
  //Now recursively scan the sub directories
  tmp = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot , QDir::Name);
  for(int i=0; i<tmp.length(); i++){
    if(stopsearch){ return true; }
    if( skipDirs.contains(dir.absoluteFilePath(tmp[i])) || tmp[i]=="proc" ){ continue; } //this dir is skipped
       //Special case - skip the "proc" directory heirarchy (highly-recursive layout for *every* process which is running)
    if( searchDir(dir.absoluteFilePath(tmp[i])) ){ return true; }
  }
  return false;
}
コード例 #6
0
ファイル: RockLiningGlobal.cpp プロジェクト: Kubeu/trunk
void RockLiningGlobal::action(){
	const double PI = 3.14159;
	if (openingCreated == true && installed == false){
		
		double angleInterval = 2.0*PI/static_cast<double>(totalNodes);
		for (int n=0; n<totalNodes;n++){
			double currentAngle = 0.0 + n*angleInterval; /* from 0 degrees east */
			double unitX = cos(currentAngle);
			double unitY = sin(currentAngle);
			Vector3r searchDir(unitX,0,unitY);

			vector<double> distanceFrOpening; vector<int> IDs;
			double outerRadius = openingRad + 1.0;
			FOREACH(const shared_ptr<Body>& b, *scene->bodies){
				if (!b) continue;
				if (b->isClump() == true) continue;
				PotentialBlock* pb=static_cast<PotentialBlock*>(b->shape.get()); 
				if(!pb) continue;
				if(pb->isBoundary == true || pb->erase== true || pb->isLining==true){continue;}	
				State* state1 = b->state.get();				
				Vector3r intersectionPt(0,0,0);
				if ( installLining(pb,  state1, startingPoint, searchDir, outerRadius, intersectionPt )){
					IDs.push_back(b->id);
					distanceFrOpening.push_back((intersectionPt-startingPoint).norm());
					//std::cout<<"currentAngle: "<<currentAngle<<", b->id: "<<b->id<<", dist: "<<(intersectionPt-startingPoint).norm()<<endl;
				}
			}

			/* find closest block */
			int totalBlocks = IDs.size(); 
			double closestDistance = 100000.0; 
			int closestID=0;
			for (int i=0; i<totalBlocks; i++){
				if ( distanceFrOpening[i] < closestDistance){
					closestID = IDs[i];
					closestDistance = distanceFrOpening[i];
				}			
			}
			stickIDs.push_back(closestID);
			IDs.clear();distanceFrOpening.clear();
//std::cout<<"closestID: "<<closestID<<endl;
	
			/* find intersection with edges of polygon */
			Vector3r jointIntersection (0,0,0); 
			State* state1 = Body::byId(closestID,scene)->state.get();
			Shape* shape1 = Body::byId(closestID,scene)->shape.get();
			PotentialBlock *pb=static_cast<PotentialBlock*>(shape1);
			int totalPlanes = pb->a.size();
			int intersectNo = 0;
			Vector3r nodeLocalPos(0,0,0); Vector3r nodeGlobalPos(0,0,0);
//std::cout<<"totalPlanes: "<<totalPlanes<<endl;
			double closestPlaneDist = 1000000;
			for (int i=0; i<totalPlanes; i++){						
					Vector3r plane = state1->ori*Vector3r(pb->a[i], pb->b[i], pb->c[i]); double planeD = plane.dot(state1->pos) + pb->d[i] +pb->r;
					if ( intersectPlane(pb, state1,startingPoint,searchDir, outerRadius, jointIntersection, plane, planeD)){
						double distance = jointIntersection.norm();
						if (distance < closestPlaneDist){
							closestPlaneDist = distance;
							nodeLocalPos = state1->ori.conjugate()*(jointIntersection-state1->pos);
							nodeGlobalPos=jointIntersection;
						}
						
					}
			}
			if(nodeGlobalPos.norm() > 1.03*openingRad){ nodeGlobalPos=1.03*openingRad*searchDir;} 
			//if(nodeGlobalPos.norm() < 0.98*openingRad){ continue;} 
			//initOverlap = interfaceTension/interfaceStiffness;
			nodeGlobalPos = nodeGlobalPos + searchDir*initOverlap;
			localCoordinates.push_back(nodeLocalPos);
			refPos.push_back(nodeGlobalPos);
			int nodeID = insertNode(nodeGlobalPos, lumpedMass, contactLength);
			blockIDs.push_back(nodeID); //(nodeID); //(closestID);
			refOri.push_back(Quaternionr::Identity()); //(state1->ori);
			installed = true;
			
			axialForces.push_back(0.0);
			shearForces.push_back(0.0);
			moment.push_back(0.0);
			sigmaMax.push_back(0.0);
			sigmaMin.push_back(0.0);
			displacement.push_back(0.0);
			radialDisplacement.push_back(0.0);
		}
		totalNodes=blockIDs.size();

	
		/* Assembling global stiffness matrix */
		for (int n=0; n<totalNodes;n++){
			int nextID = n+1;
			if(nextID==totalNodes){nextID=0;}
			double Length = (refPos[nextID]-refPos[n]).norm();
			lengthNode.push_back(Length);
			
			Vector3r localDir = refPos[nextID]-refPos[n];
			localDir.normalize(); refDir.push_back(localDir);
			double angle = acos(localDir.dot(Vector3r(1,0,0)));
			Vector3r signAngle =  Vector3r(1,0.0,0).cross(localDir); 

			if (signAngle.dot(Vector3r(0,-1.0,0)) < 0.0){angle =2.0*PI - angle;}			
			refAngle.push_back(angle);
			std::cout<<"angle "<<n<<" : "<<angle/PI*180.0<<endl;

			
		}
	}
コード例 #7
0
bool ConfigOptionsDialog::ParseConfigOptions(const ConfigToken &setProfile)
{
  wxStandardPaths stdPaths;

  // Reset any grid values
  gridValues.childHeaderArray.clear();
  gridValues.childSelectArray.clear();

  // Get the directory that contains the main options
  wxFileName mainConfigDef;
  mainConfigDef.AssignDir(stdPaths.GetDataDir());
  mainConfigDef.AppendDir("MainLib");
  mainConfigDef.SetFullName(wxT("gliConfig_Definition.ini"));

  // Parse the main config file
  if(!ParseConfigFile(mainConfigDef, false))
  {
    return false;
  }

  // Get the plugin directory
  wxFileName pluginDir;
  pluginDir.AssignDir(stdPaths.GetDataDir());
  pluginDir.AppendDir("Plugins");
  wxDir searchDir(pluginDir.GetFullPath());
  
  // Search for all directories under the "Plugins" directory
  wxArrayString foundDirs;
  DirListTraverse dirTraverse(foundDirs);
  searchDir.Traverse(dirTraverse);

  // Loop for all plugins directories and get any plugin options  
  for(uint i=0; i<foundDirs.size(); i++)
  {
    wxFileName pluginConfigDef;
    pluginConfigDef.AssignDir(foundDirs[i]);
    pluginConfigDef.SetFullName(wxT("config_Definition.ini"));

    // If the file exists
    if(pluginConfigDef.FileExists())
    {
      // Parse the main config file
      if(!ParseConfigFile(pluginConfigDef, true))
      {
        return false;
      }
    }
    else
    {
      wxLogWarning("Unable to find plugin config definition (%s) - file does not exist", pluginConfigDef.GetFullPath().c_str());
    }
  }

  // Set the defualts from the passed config options
  if(!SetProfileData(setProfile, gridValues))
  { 
    wxLogError("Unable to set selected config options");     
    return false;
  }
   
  // Lock and clear the property grid 
  propGrid->Freeze();

  // Add the options to the property grid
  string parentPath("");
  if(!AddPropGridHeader(gridValues, 0, true, parentPath))
  {
    propGrid->Thaw();
    return false;
  }
  
  // Release the property grid
  propGrid->Thaw();

  return true;
}
コード例 #8
0
ファイル: MantidHelpWindow.cpp プロジェクト: DanNixon/mantid
/**
 * Determine the location of the collection file, "mantid.qhc". This
 * checks in multiple locations and can throw an exception. For more
 * information see
 *http://doc.qt.digia.com/qq/qq28-qthelp.html#htmlfilesandhelpprojects
 *
 * @param binDir The location of the mantid executable.
 */
void MantidHelpWindow::findCollectionFile(std::string &binDir) {
  // this being empty notes the feature being disabled
  m_collectionFile = "";

  QDir searchDir(QString::fromStdString(binDir));

  // try next to the executable
  QString path = searchDir.absoluteFilePath(COLLECTION_FILE);
  g_log.debug() << "Trying \"" << path.toStdString() << "\"\n";
  if (searchDir.exists(COLLECTION_FILE)) {
    m_collectionFile = path.toStdString();
    return;
  }

  // try where the builds will put it for a single configuration build
  searchDir.cdUp();
  if (searchDir.cd("docs")) {
    searchDir.cd("qthelp");
    path = searchDir.absoluteFilePath(COLLECTION_FILE);
    g_log.debug() << "Trying \"" << path.toStdString() << "\"\n";
    if (searchDir.exists(COLLECTION_FILE)) {
      m_collectionFile = path.toStdString();
      return;
    }
  }
  // try where the builds will put it for a multi-configuration build
  searchDir.cdUp();
  if (searchDir.cd("docs")) {
    searchDir.cd("qthelp");
    path = searchDir.absoluteFilePath(COLLECTION_FILE);
    g_log.debug() << "Trying \"" << path.toStdString() << "\"\n";
    if (searchDir.exists(COLLECTION_FILE)) {
      m_collectionFile = path.toStdString();
      return;
    }
  }

  // try in windows/linux install location
  searchDir = QDir(QString::fromStdString(binDir));
  searchDir.cdUp();
  searchDir.cd("share");
  searchDir.cd("doc");
  path = searchDir.absoluteFilePath(COLLECTION_FILE);
  g_log.debug() << "Trying \"" << path.toStdString() << "\"\n";
  if (searchDir.exists(COLLECTION_FILE)) {
    m_collectionFile = path.toStdString();
    return;
  }

  // try a special place for mac/osx
  searchDir = QDir(QString::fromStdString(binDir));
  searchDir.cdUp();
  searchDir.cdUp();
  searchDir.cd("share");
  searchDir.cd("doc");
  path = searchDir.absoluteFilePath(COLLECTION_FILE);
  g_log.debug() << "Trying \"" << path.toStdString() << "\"\n";
  if (searchDir.exists(COLLECTION_FILE)) {
    m_collectionFile = path.toStdString();
    return;
  }

  // all tries have failed
  g_log.information("Failed to find help system collection file \"" +
                    COLLECTION_FILE.toStdString() + "\"");
}
コード例 #9
0
ファイル: proyecto.cpp プロジェクト: danyacosta91/FAT16
bool FAT::mkdir(string dirName){
	if (strlen(dirName.c_str()) != 0 && strlen(dirName.c_str()) < 10){ // Validacion de cadena
		if (searchDir(dirName) == false){ //Validacion de directorio existente en la carpeta actual
			d_entry newDir;
			newDir._free = false;
			strcpy(newDir.name, dirName.c_str());
			newDir._dir = true;
			newDir._cDate = time(0);
			newDir._cluster = freeIndex.front();						
			newDir._size = 4096;	
			if (currentDir == NULL){ //Se encuentra en la root
				for (int i = 0; i < 512; i++){
					if (_root[i]._free == true){
						_root[i] = newDir;

						_dataRegion[freeIndex.front()].entries = new d_entry[128];
						d_entry x;
						x._free = true;
						string c = "NULL";
						strcpy(x.name, c.c_str());
						x._dir = false;
						x._cDate = 0;
						x._cluster = 0xFFFF;	
						x._size =  0xFFFFFFFF;
						for (int i = 0; i < 128; i++){
							_dataRegion[freeIndex.front()].entries[i] = x;
						}
						freeIndex.pop();
						return true;
					}
				}
				return false;
			} else { //Si se encuentra en el Data Region
				if (_FAT[currentDir->_cluster] == 0xFFFF){
					unsigned short currentIndex = currentDir->_cluster; 
					for (int i = 0; i < 128; i++){
						if (_dataRegion[currentDir->_cluster].entries[i]._free == true){
							_dataRegion[currentDir->_cluster].entries[i] = newDir;
							_dataRegion[freeIndex.front()].entries = new d_entry[128];
							d_entry x;
							x._free = true;
							string c = "NULL";
							strcpy(x.name, c.c_str());
							x._dir = false;
							x._cDate = 0;
							x._cluster = 0xFFFF;	
							x._size =  0xFFFFFFFF;
							for (int i = 1; i < 128; i++){
								_dataRegion[freeIndex.front()].entries[i] = x;
							}
							_dataRegion[freeIndex.front()].entries[0] = *currentDir;
							freeIndex.pop();
							return true;
						}
					}
					freeIndex.pop();
					currentIndex = freeIndex.front();
					_FAT[currentDir->_cluster] = currentIndex;

					
					_dataRegion[currentIndex].entries[0] = newDir;

					_dataRegion[newDir._cluster].entries = new d_entry[128];
					d_entry x;
					x._free = true;
					string c = "NULL";
					strcpy(x.name, c.c_str());
					x._dir = false;
					x._cDate = 0;
					x._cluster = 0xFFFF;	
					x._size =  0xFFFFFFFF;
					for (int i = 1; i < 128; i++){
						_dataRegion[freeIndex.front()].entries[i] = x;
					}
					_dataRegion[newDir._cluster].entries[0] = *currentDir;
					freeIndex.pop();
					return true;
				} else {
					unsigned short currentIndex = currentDir->_cluster;
					while (_FAT[currentIndex] != 0xFFFF){
						currentIndex = _FAT[currentIndex];
					}
					for (int i = 0; i < 128; i++){
						if(_dataRegion[currentIndex].entries[i]._free){
							_dataRegion[currentIndex].entries[i] = newDir;

							_dataRegion[newDir._cluster].entries = new d_entry[128];
							d_entry x;
							x._free = true;
							string c = "NULL";
							strcpy(x.name, c.c_str());
							x._dir = false;
							x._cDate = 0;
							x._cluster = 0xFFFF;	
							x._size =  0xFFFFFFFF;
							for (int i = 1; i < 128; i++){
								_dataRegion[freeIndex.front()].entries[i] = x;
							}
							_dataRegion[freeIndex.front()].entries[0] = *currentDir;
							freeIndex.pop();							
							return true;
						}
					}
					freeIndex.pop();
					currentIndex = freeIndex.front();
					_FAT[currentDir->_cluster] = currentIndex;

					
					_dataRegion[currentIndex].entries[0] = newDir;

					_dataRegion[newDir._cluster].entries = new d_entry[128];
					d_entry x;
					x._free = true;
					string c = "NULL";
					strcpy(x.name, c.c_str());
					x._dir = false;
					x._cDate = 0;
					x._cluster = 0xFFFF;	
					x._size =  0xFFFFFFFF;
					for (int i = 1; i < 128; i++){
						_dataRegion[freeIndex.front()].entries[i] = x;
					}
					_dataRegion[newDir._cluster].entries[0] = *currentDir;
					freeIndex.pop();
					return true;
				}
			}
		} else{
			return false;
		}
	} else {
		return false;
	}
}