コード例 #1
0
ファイル: SBWorkspace.cpp プロジェクト: bbowman/WinObjC
void SBWorkspace::findSchemes(const String& containerAbsPath) {
    if (containerAbsPath.empty()) {
        SBLog::error() << "No container specified for schemes." << std::endl;
        return;
    }

    StringList schemePaths;

    // Find all scheme files in the shareddata directory
    String sharedDir = joinPaths(containerAbsPath, "xcshareddata");
    if (fileExists(sharedDir))
        findFiles(sharedDir.c_str(), "*.xcscheme", DT_REG, true, schemePaths);

    String userDir = joinPaths(containerAbsPath, "xcuserdata");
#if !defined(_MSC_VER)
    // Only search the current user's data directory
    String user;
    sb_getenv("USER", user);
    userDir = joinPaths(userDir, user + ".xcuserdatad");
#endif

    // Find scheme files in the xcuserdata directory
    if (fileExists(userDir))
        findFiles(userDir.c_str(), "*.xcscheme", DT_REG, true, schemePaths);

    // Try to create a XCScheme out of each path
    StringList::iterator it = schemePaths.begin();
    StringList::iterator itEnd = schemePaths.end();
    for (; it != itEnd; it++) {
        XCScheme* scheme = XCScheme::createFromFile(*it, containerAbsPath);
        if (scheme) {
            m_schemes.push_back(scheme);
        }
    }
}
コード例 #2
0
ファイル: search.cpp プロジェクト: MortimerBlater/paintown
void Searcher::CharacterSearch::search(){
    /* Quit if either we run out of paths to process or if the searcher
     * is paused
     */
    while (paths.size() > 0 && searchingCheck.get()){
        Filesystem::AbsolutePath path = paths.front();
        paths.erase(paths.begin());
        owner.addCharacters(findFiles(path, "def"));
        vector<std::string> containers = Storage::containerTypes();
        for (vector<std::string>::iterator it = containers.begin(); it != containers.end(); it++){
            owner.addCharacters(findFiles(path, *it));
        }
    }
}
コード例 #3
0
ファイル: FileFinder.cpp プロジェクト: suykerbuyk/solidFire
	void FileFinder::findFiles(fs::path aDir, file_path_list_t& cwd_paths, bool as_thread)
	{
		typedef std::list<file_path_list_t> child_paths_t;
		typedef std::list<file_path_list_t>::iterator child_paths_iterator_t;

		child_paths_t child_paths;
		if ( fs::exists(aDir) && fs::is_directory(aDir))
		{
			boost::thread_group threads;
			fs::directory_iterator end_iter;
			for( fs::directory_iterator dir_iter(aDir) ;  dir_iter != end_iter ;  ++dir_iter)
			{
				if (fs::is_regular_file(dir_iter->status()) )
				{
					if (fileExtMatch(dir_iter->path()))
					{
						cwd_paths.push_back(dir_iter->path());
					}
				} 
				else if (fs::is_directory(dir_iter->status()))
				{
					file_path_list_t child;
					child_paths.push_back(child);

					if (p_thread_counter->TryInc())
					{
						threads.create_thread( 
							boost::bind(&FileFinder::findFiles, 
							this, 
							dir_iter->path(), 
							boost::ref(child_paths.back()),true));
					}
					else
					{
						findFiles(dir_iter->path(), boost::ref(child_paths.back()), false);
					}
				}
				else
				{
					std::cerr << "Skipping: " << dir_iter->path() << std::endl;
				}
			}
			threads.join_all();
			//cwd_paths.sort();
			if (child_paths.size())
			{
				child_paths_iterator_t child_end = child_paths.end();
				child_paths_iterator_t child_itr = child_paths.begin();
				while(child_itr != child_end)
				{
					cwd_paths.merge(*child_itr);
					++child_itr;
				}
			}
		}
		if (as_thread)
		{
			p_thread_counter->Dec();
		}
	}
コード例 #4
0
ファイル: window.cpp プロジェクト: Mr-Kumar-Abhishek/qt
//! [3]
void Window::find()
{
    filesTable->setRowCount(0);

    QString fileName = fileComboBox->currentText();
    QString text = textComboBox->currentText();
    QString path = directoryComboBox->currentText();
//! [3]

    updateComboBox(fileComboBox);
    updateComboBox(textComboBox);
    updateComboBox(directoryComboBox);

//! [4]
    currentDir = QDir(path);
    QStringList files;
    if (fileName.isEmpty())
        fileName = "*";
    files = currentDir.entryList(QStringList(fileName),
                                 QDir::Files | QDir::NoSymLinks);

    if (!text.isEmpty())
        files = findFiles(files, text);
    showFiles(files);
}
コード例 #5
0
void *connection_handler(void *arg){
    int err,length;
    char* directory;
    QNode* node;
    int newsock = ((information*)arg)->newsock;
    int queue_size = ((information*)arg)->queue_size;
    pthread_mutex_t *clientMutex = malloc(sizeof(pthread_mutex_t));
//---------------------------------------------
    if ( err = pthread_detach(pthread_self())){
        perror2("pthread_detach",err);
        exit(1);
    }
    pthread_mutex_init(clientMutex,NULL ) ; /* Initialize client mutex */

    if (read_all(newsock,&length,sizeof(int)) != sizeof(int) )
        perror_exit("read");
    directory = malloc(length);
    if (read_all(newsock,directory,length) != length)
        perror_exit("read");
    //print directory
    //printf("directory is: %s\n",directory);
    printf("[Thread: %ld]: About to scan directory Server\n",pthread_self());
    fflush(stdout);
    findFiles(directory,newsock,queue_size,clientMutex);
    //create ack
    node = createQNode();
    node->client_sock = newsock;
    node->buf = NULL;
    node->clientMutex = clientMutex;
    place(workQueue,node,queue_size);
    pthread_cond_broadcast(&cond_empty);
    pthread_exit(NULL);
}
コード例 #6
0
void findFiles(const String& searchDir, const StringVec& filePatterns, int fileType, bool recursive, StringList& results)
{
  struct dirent *entry;
  DIR *dir = opendir(searchDir.c_str());
  
  if (!dir) {
    SBLog::warning() << "Failed to open \"" << searchDir << "\" directory for file search." << std::endl;
    return;
  }
  
  while ((entry = readdir(dir))) {
    // Ignore . and .. so we dont accidentally recurse on them
    if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
      continue;
      
    // Get full path to entry
    String path = joinPaths(searchDir, entry->d_name);
    
    // Check if the file matches our search criteria
    if (entry->d_type == fileType && matchWildcardList(entry->d_name, filePatterns)) {
      results.push_back(path);
      continue;
    }
    
    // Possibly recurse
    if (entry->d_type == DT_DIR && recursive) {
      findFiles(path, filePatterns, fileType, recursive, results);
    }
  }

  closedir(dir);
}
コード例 #7
0
ファイル: FLUtil.cpp プロジェクト: afibanez/eneboo
QStringList FLUtil::findFiles(const QStringList &paths, const QString &filter,
                              bool breakOnFirstMatch)
{
  QStringList result, more;
  QStringList::Iterator it;
  for (uint i = 0; i < paths.size(); i++) {
    QDir dir(paths[i]);
    more = dir.entryList(filter, QDir::Files);
    for (it = more.begin(); it != more.end(); ++it) {
      if (breakOnFirstMatch)
        return paths[i] + QString::fromLatin1("/") + *it;
      result.append(paths[i] + QString::fromLatin1("/") + *it);
    }
    more = dir.entryList(QDir::Dirs).grep(QRegExp("[^.]"));
    for (it = more.begin(); it != more.end(); ++it)
      *it = paths[i] + QString::fromLatin1("/") + *it;
    qApp->processEvents();
    more = findFiles(more, filter, breakOnFirstMatch);
    for (it = more.begin(); it != more.end(); ++it) {
      if (breakOnFirstMatch)
        return *it;
      result.append(*it);
    }
  }
  return result;
}
コード例 #8
0
ファイル: search.cpp プロジェクト: MortimerBlater/paintown
static vector<Filesystem::AbsolutePath> findFiles(const Filesystem::RelativePath & path, const std::string & extension){
    try{
        return findFiles(Storage::instance().find(path), extension);
    } catch (const Filesystem::NotFound & fail){
        return vector<Filesystem::AbsolutePath>();
    }
}   
コード例 #9
0
void CFileSelectDialog::ScanDir()
	{
	_LOG(_L("0"));
	TInt i=0;
	CDir* results=NULL;
	TFindFile findFiles(iFs);
	TBuf<5> mask(_L("*"));
	findFiles.FindWildByDir(mask,iCurrentPath,results);
	if (results==NULL){return;}
	_LOG(_L("2"));
	for (i=0;i<results->Count();i++)
		{
		_LOGDATA(_L("3 %d"),i);
		if (((TEntry)(*results)[i]).IsDir())
		{
		TBuf<255> buf;
		buf.Copy(_L("["));
		buf.Append(((TEntry)(*results)[i]).iName);
		buf.Append(_L("]"));
		iArray->AppendL(buf);}
		}
	if (iType!=EFolder)
	{
	for (i=0;i<results->Count();i++)
		{
		_LOGDATA(_L("4 %d"),i);
		if ((!((TEntry)(*results)[i]).IsDir())&&((TEntry)(*results)[i]).iName.Match(iMask)!=KErrNotFound)
			{iArray->AppendL(((TEntry)(*results)[i]).iName);}
		}
	}
	_LOG(_L("Exit from ScanDir"));
}
コード例 #10
0
ファイル: c_imt.c プロジェクト: jhunkeler/hstcal
IRAFPointer c_imtopen (char *pattern) {

/* Create a file name template object.
argument:
char *pattern           i: name of file; wildcard characters are supposed to be
                           allowed, but currently only one explicit file name
                           may be given
function value          o: file name template descriptor
*/

        ImtDescr *imt_descr;
        IRAFPointer imt;

        imt_descr = (ImtDescr *)calloc (1, sizeof(ImtDescr));
        imt_descr->pattern = (char *)calloc (strlen(pattern)+1, sizeof(char));
        strcpy (imt_descr->pattern, pattern);

        /* allocate and populate the list of file names */
        findFiles (imt_descr);

        imt_descr->current_index = 0;

        imt = (void *)imt_descr;

        return imt;
}
コード例 #11
0
void CMCIPlayerMgr::init(HWND hWnd)
{
	m_mciPlayer.init(hWnd);

	m_strRoot = g_strExeFullPath + "\\music\\";
	findFiles(m_strRoot, m_vAllFiles);
}
コード例 #12
0
ファイル: grepwidget.cpp プロジェクト: DomDumont/trp
void GrepWidget::find()
{
    output->clear();
    QString text = textComboBox->currentText();
    updateComboBox(textComboBox);
    QStringList files;
    currentDir = m_mainWindow->m_projectWidget->rootDir;
    files = m_mainWindow->m_projectWidget->GetScriptFiles();
    if (!text.isEmpty())
        files = findFiles(files, text);
    showFiles(files);
/*








    currentDir = QDir(path);
    QStringList files;
    if (fileName.isEmpty())
        fileName = "*";
    files = currentDir.entryList(QStringList(fileName),
                                 QDir::Files | QDir::NoSymLinks);

    if (!text.isEmpty())
        files = findFiles(files, text);
    showFiles(files);
*/
}
コード例 #13
0
HMENU MainWindow::createMenu()
{
	HMENU menu = GetSubMenu(LoadMenu(nullptr, MAKEINTRESOURCE(IDR_MENU)), 0);
	auto items = settings::settings()[L"menu"];
	size_t count = 0;
	Table* table = nullptr;
	for (auto t : m_tables)
	{
		if (t->isVisible())
		{
			table = t;
			break;
		}
	}
	m_menuItems.clear();
	for (auto item : items)
	{
		auto name = item[L"name"].asString();
		auto path = item[L"path"].asString();
		auto args = item[L"args"].asString();
		auto verb = item[L"verb"].asString();
		auto hidden = item[L"hidden"].asNumber() != 0;
		if (table)
		{
			name = table->expandString(name);
			path = table->expandString(path);
			args = table->expandString(args);
		}
		findFiles(name, L"MenuItem", path, false, [&](const std::wstring& name, const std::wstring& path) {
			MenuItem menuItem = { path, args, verb, hidden };
			m_menuItems.push_back(menuItem);
			MENUITEMINFO item = { 0 };
			item.cbSize = sizeof(item);
			item.fMask = MIIM_STRING | MIIM_ID | MIIM_DATA;
			item.fType = MFT_STRING;
			item.wID = ID_USER_MENU;
			item.dwItemData = DWORD(m_menuItems.size() - 1);
			item.dwTypeData = const_cast<LPWSTR>(name.c_str());
			item.cch = path.length();
			InsertMenuItem(menu, count++, TRUE, &item);
		});
	}
	if (count)
	{
		MENUITEMINFO item = { 0 };
		item.cbSize = sizeof(item);
		item.fMask = MIIM_FTYPE;
		item.fType = MFT_SEPARATOR;
		InsertMenuItem(menu, count, TRUE, &item);
	}

	MENUINFO mi;
	memset(&mi, 0, sizeof(mi));
	mi.cbSize = sizeof(mi);
	mi.fMask = MIM_STYLE;
	mi.dwStyle = MNS_NOTIFYBYPOS;
	SetMenuInfo(menu, &mi);

	return menu;
}
コード例 #14
0
ファイル: window.cpp プロジェクト: Jinxiaohai/QT
//! [3]
void Window::find() {
  filesTable->setRowCount(0);

  QString fileName = fileComboBox->currentText();
  QString text = textComboBox->currentText();
  QString path = QDir::cleanPath(directoryComboBox->currentText());
  currentDir = QDir(path);
  //! [3]

  updateComboBox(fileComboBox);
  updateComboBox(textComboBox);
  updateComboBox(directoryComboBox);

  //! [4]
  QStringList filter;
  if (!fileName.isEmpty()) filter << fileName;
  QDirIterator it(path, filter,
                  QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot,
                  QDirIterator::Subdirectories);
  QStringList files;
  while (it.hasNext()) files << it.next();
  if (!text.isEmpty()) files = findFiles(files, text);
  files.sort();
  showFiles(files);
}
コード例 #15
0
ファイル: Directory.cpp プロジェクト: TonixOS/libcloudos
  bool Directory::findFiles( std::vector< fs::path >& p_storage, const std::string& p_phrase, ushort p_mode, ushort p_type, uint p_recursion_level ) {
    LOG_D() << "try to find files for directory: " << c_directory.string()
            << " and phrase: " << p_phrase << " type: " << p_type << " mode: " << p_mode;
    
    if( reportInvalidObjectError( __PRETTY_FUNCTION__ ) ) {
      return false;
    }

    if( p_phrase.empty() ) {
      LOG_D() << "got empty phrase to search for... Abort!";
      return false;
    }
    
    bool file_match = false;
    
    fs::directory_iterator di( c_directory ), eod; // eod == endOfDirectory
    
    BOOST_FOREACH( const fs::path& file, std::make_pair(di,eod) ) {
      bool file_type_match = false;
      
      if( fs::is_directory( file ) ) {
        file_type_match = p_type & FILE_TYPE_DIRECTORY;
        
        if( p_recursion_level > 0 ) {
          c_directory = file;
          file_match = findFiles( p_storage, p_phrase, p_mode, p_type, p_recursion_level - 1 ) || file_match;
          c_directory = file.parent_path();
        }
      }
      file_type_match = ( p_type & FILE_TYPE_REGULAR && fs::is_regular_file( file ) ) || file_type_match;
      file_type_match = ( p_type & FILE_TYPE_SYMLINK && fs::is_symlink( file ) ) || file_type_match;
      
      if( file_type_match ) {
        std::string filename = file.filename().string();
        std::size_t phrase_length   = p_phrase.length();
        std::size_t filename_length = filename.length();
        //LOG_T() << "file type matches, checking name... got " << filename << " looking for " << p_phrase;
        
        // if we match against a string, at least, it has to be sized equaly
        if( p_mode & LOOKUP_BY_REGEX || ( p_mode > LOOKUP_BY_REGEX && filename_length >= phrase_length ) ) {
          
          if( ( p_mode & LOOKUP_BY_FULLMATCH  && ( filename == p_phrase ) )                               ||
              ( p_mode & LOOKUP_BY_STARTSWITH && ( filename.substr(0, phrase_length) == p_phrase ) )      ||
              ( p_mode & LOOKUP_BY_REGEX      && boost::regex_match(filename, boost::regex( p_phrase )) ) ||
              ( p_mode & LOOKUP_BY_ENDSWITH   && ( filename.substr( filename_length - phrase_length ) == p_phrase ) ) ) {
            p_storage.push_back( file );
            file_match = true;
            LOG_D() << "found file: " << file.string();
            
            // check again, as we migth be able to imrove performance here...
            // on full match, there could be just one entry in one directory level
            if( p_recursion_level == 0 && p_mode & LOOKUP_BY_FULLMATCH  && ( filename == p_phrase ) ) {
              return file_match;
            }
          }
          
        } // if LOOKUP_BY_REGEX xor...
      } // if file_type_match
    } // BOOST_FOREACH
コード例 #16
0
ファイル: findus.c プロジェクト: JBosom/TIPS_launchpad
Retour* find(int argc, char ** argv)
{
	/*Construction de la structure de paramètres*/
	int i, j;
	int echange;
	char temp[512];
	parametres * params = null;
	params = lecture_param(argc, argv);
	Retour* ret = null;
	ret = (Retour*) calloc(1, sizeof(Retour));
	
	char *** retour = calloc(1, sizeof(char **));
	int * taille = calloc(1, sizeof(int));
	if(!retour)
	{
		perror("calloc");
		exit(EXIT_FAILURE);
	}
	if(!taille)
	{
		perror("calloc");
		exit(EXIT_FAILURE);
	}
	
	findFiles(params, getCheminDepart(params), 0, retour, taille);
	
	if(params && params->sort)
	{
		do
		{
			echange = 0;
			for(j = 0; j < *taille - 1; j++)
			{
				if(strcmp((*retour)[j], (*retour)[j+1]) > 0)
				{
					strcpy(temp, (*retour)[j]);
					(*retour)[j] = realloc((*retour)[j], strlen((*retour)[j+1])+1);
					strcpy((*retour)[j], (*retour)[j+1]);
					(*retour)[j+1] = realloc((*retour)[j+1], strlen(temp)+1);
					strcpy((*retour)[j+1], temp);
					echange = 1;
				}
			}
		} while(echange);
	}
	
	for(i=0; params->cmds[i]; i++)
	{
		detruire_commande(params->cmds[i]);
	}
	free(params->cmds);
	free(params->path);
	free(params);
	
	ret->retour = retour;
	ret->taille = taille;
	
	return ret;
}
コード例 #17
0
ファイル: File.cpp プロジェクト: JamesLinus/pipeline
 bool findFiles( std::string const& extension, std::vector<std::string> const& paths, std::vector<std::string> & results )
 {
   for ( std::vector<std::string>::const_iterator it = paths.begin() ; it != paths.end() ; ++it )
   {
     findFiles( extension, *it, results );
   }
   return( results.empty() );
 }
コード例 #18
0
    //-----------------------------------------------------------------------
    FileInfoListPtr FileSystemArchive::listFileInfo(bool recursive, bool dirs)
    {
        FileInfoListPtr ret(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles("*", recursive, dirs, 0, ret.getPointer());

        return ret;
    }
コード例 #19
0
    //-----------------------------------------------------------------------
    FileInfoListPtr FileSystemArchive::findFileInfo(const String& pattern,
        bool recursive, bool dirs) const
    {
		FileInfoListPtr ret(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles(pattern, recursive, dirs, 0, ret.getPointer());

        return ret;
    }
コード例 #20
0
    //-----------------------------------------------------------------------
    FileInfoListPtr FileSystemArchive::listFileInfo(bool recursive, bool dirs)
    {
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
        FileInfoListPtr ret(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles("*", recursive, dirs, 0, ret.getPointer());

        return ret;
    }
コード例 #21
0
    //-----------------------------------------------------------------------
    StringVectorPtr FileSystemArchive::list(bool recursive, bool dirs)
    {
		// directory change requires locking due to saved returns
		StringVectorPtr ret(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles("*", recursive, dirs, ret.getPointer(), 0);

        return ret;
    }
コード例 #22
0
ファイル: resources.cpp プロジェクト: tapio/weep
std::vector<string> Resources::listFiles(const string& path, const string& filter) const
{
	std::vector<string> files;
	for (auto& it : m_paths) {
		string fullPath = it + getCanonicalDir(path);
		findFiles(files, fullPath, filter);
	}
	return files;
}
コード例 #23
0
ファイル: psaver.cpp プロジェクト: AnatolyRugalev/Pastexen
pSaver::pSaver() :
    QThread(0)
{
    moveToThread(this);
    this->start(QThread::LowPriority);

    findFiles();

    pThis = this;
}
コード例 #24
0
ファイル: search.cpp プロジェクト: MortimerBlater/paintown
void Searcher::StageSearch::search(){
    while (paths.size() > 0 && searchingCheck.get()){
        Filesystem::AbsolutePath path = paths.front();
        paths.erase(paths.begin());
        owner.addStages(findFiles(path, "def"));
    }

    PaintownUtil::Thread::ScopedLock scoped1(searchingLock);
    isDone = paths.size() == 0;
}
コード例 #25
0
ファイル: file_dialog.cpp プロジェクト: nadult/FreeFT
	void FileDialog::updateList() {
		m_list_box->clear();

		auto files = findFiles(m_dir_path, FindFiles::directory | FindFiles::regular_file |
				                           FindFiles::relative | FindFiles::include_parent);

		std::sort(files.begin(), files.end());
		for(int n = 0; n < (int)files.size(); n++)
			m_list_box->addEntry(files[n].path.c_str(), files[n].is_dir? ColorId::yellow : ColorId::white);
	}
コード例 #26
0
void MusicDesktopWallpaperWidget::viewButtonPressed()
{
    QString path =  QFileDialog::getExistingDirectory(this, QString(), "./");
    if(!path.isEmpty())
    {
        ui->urlLineEdit->setText(path);
    }

    findFiles(path);
}
コード例 #27
0
    //-----------------------------------------------------------------------
    StringVectorPtr FileSystemArchive::list(bool recursive, bool dirs)
    {
		// directory change requires locking due to saved returns
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
		StringVectorPtr ret(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles("*", recursive, dirs, ret.getPointer(), 0);

        return ret;
    }
コード例 #28
0
    //-----------------------------------------------------------------------
    StringVectorPtr FileSystemArchive::find(const String& pattern,
                                            bool recursive, bool dirs)
    {
		StringVectorPtr ret(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles(pattern, recursive, dirs, ret.getPointer(), 0);

        return ret;

    }
コード例 #29
0
bool Sequence::onInit() {
	CLOG(LTRACE) << "Sequence::initialize\n";

	if (!findFiles()) {
		CLOG(LERROR) << name() << ": There are no files matching regex "
				<< prop_pattern << " in " << prop_directory;
		return false;
	}

	return true;
}
コード例 #30
0
    //-----------------------------------------------------------------------
    StringVectorPtr FileSystemArchive::find(const String& pattern,
                                            bool recursive, bool dirs)
    {
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
		StringVectorPtr ret(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

        findFiles(pattern, recursive, dirs, ret.getPointer(), 0);

        return ret;

    }