示例#1
0
bool CFileName::RecursivelyDelete()
{
  CFileNameArray ar;
  for(int i=FindFiles(*this,ar)-1;i>=0;--i){
    ::DeleteFile(ar[i]);
  }
  for(i=FindFiles(*this,ar,_T("*.*"),true,0)-1;i>=0;--i){
    ::RemoveDirectory(ar[i]);
  }
  return TRUE==::RemoveDirectory(*this);
}
示例#2
0
///@brief constructor
CClassBuilder :: CClassBuilder( s32 argc, c8** argv )
	: Argc(argc)
	, Argv(argv)
{
	const c8* c_program_name = "ClassBuilder";
	const c8* c_tmp_filename = "cbuilder.tmp";
//	const c8* c_out_filename = "cbuilder.out";
	core::stringc base_dir = "./";
//	const u32 LENGTH = 1024;

	fprintf( stdout, " ***\t\t %s\t\t\t\t*** \n", c_program_name );

	/// add lines to container
	Container filetypes;
	filetypes.push_back( "c" );
	filetypes.push_back( "cc" );
	filetypes.push_back( "cpp" );
	filetypes.push_back( "c++" );
	filetypes.push_back( "h" );
	filetypes.push_back( "hh" );
	filetypes.push_back( "hpp" );
	filetypes.push_back( "h++" );

	Container container;

	fprintf( stdout, " ***\t\t ParameterCount = %d\t\t\t\t*** \n", Argc );

	if (Argc>0)
	{
		for (s32 i=0; i<Argc; i++)
		{
			fprintf( stdout, "Argv[%d] = %s\n", i, Argv[i] );
		}

		if (Argc>=1)
		{
			FindFiles( container, Argv[1], filetypes );
		}
		else
		{
			FindFiles( container, "./", filetypes );
		}

		/// print and save container to file
		Print( container );
		StoreLines( container, c_tmp_filename );
	}

}
示例#3
0
文件: main.cpp 项目: Deledrius/Plasma
void FindPackages(std::vector<plFileName>& fileNames, std::vector<plFileName>& pathNames, const plFileName& path, const ST::string& parent_package=ST::null)
{
    std::vector<plFileName> packages;
    FindSubDirs(packages, path);
    for (int i = 0; i < packages.size(); i++)
    {
        ST::string packageName;
        if (!parent_package.is_empty())
            packageName = parent_package + ".";
        packageName += packages[i].AsString();
        std::vector<plFileName> packageFileNames;
        std::vector<plFileName> packagePathNames;
        plFileName packagePath = plFileName::Join(path, packages[i]);
        FindFiles(packageFileNames, packagePathNames, packagePath);

        // Check for the magic file to make sure this is really a package...
        if (std::find(packageFileNames.begin(), packageFileNames.end(), kModuleFile) != packageFileNames.end()) {
            for (int j = 0; j < packageFileNames.size(); j++) {
                fileNames.push_back(packageName+"."+packageFileNames[j].AsString());
                pathNames.push_back(packagePathNames[j]);
            }
            FindPackages(fileNames, pathNames, packagePath, packageName);
        }
    }
}
static void FindFiles(std::vector<std::string>& matches, const std::string& dir, const boost::regex &regexpattern, bool recurse, bool include_dirs)
{
	DIR* dp;
	struct dirent* ep;

	if (!(dp = opendir(dir.c_str())))
		return;

	while ((ep = readdir(dp))) {
		// exclude hidden files
		if (ep->d_name[0] != '.') {
			// is it a file? (we just treat sockets / pipes / fifos / character&block devices as files...)
			if (!(ep->d_type == DT_DIR)) {
				if (boost::regex_match(ep->d_name, regexpattern))
					matches.push_back(dir + ep->d_name);
			}
			// or a directory?
			else if (recurse) {
				if (include_dirs && boost::regex_match(ep->d_name, regexpattern))
					matches.push_back(dir + ep->d_name);
				FindFiles(matches, dir + ep->d_name + '/', regexpattern, recurse, include_dirs);
			}
		}
	}
	closedir(dp);
}
示例#5
0
int CFileName::FindFiles (LPCTSTR pszDir,CFileNameArray &ar,LPCTSTR pszPattern/*=_T("*.*")*/,bool bRecurse/*=true*/,DWORD dwExclude/*=FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN*/)
{
  ar.RemoveAll();
  CFileFind finder;
  BOOL bMore=finder.FindFile(CFileName(pszDir)+pszPattern);
  while (bMore)    {
    bMore = finder.FindNextFile();
    if(!finder.IsDots() && !finder.MatchesMask(dwExclude)){
      CFileName strFile(finder.GetFilePath());
      ar.Add(strFile);
    }
  }
  if(bRecurse){
    CFileFind finder;
    BOOL bMore=finder.FindFile(CFileName(pszDir)+_T("*.*"));
    while (bMore)    {
      bMore = finder.FindNextFile();
      if(!finder.IsDots() && finder.IsDirectory()){
        CFileNameArray ar2;
        FindFiles(finder.GetFilePath(),ar2,pszPattern,bRecurse,dwExclude);
        ar.Append(ar2);
      }
    }
  }
  return ar.GetSize();
}
示例#6
0
int FileMisc::FindFiles(const CString& sFolder, CStringArray& aFiles, LPCTSTR szPattern)
{
	CFileFind ff;
	CString sSearchSpec;

	MakePath(sSearchSpec, NULL, sFolder, szPattern, NULL);

	BOOL bContinue = ff.FindFile(sSearchSpec);

	while (bContinue)
	{
		bContinue = ff.FindNextFile();

		if (!ff.IsDots())
		{
			if (ff.IsDirectory())
			{
				FindFiles(ff.GetFilePath(), aFiles, szPattern);
			}
			else
			{
				aFiles.Add(ff.GetFilePath());
			}
		}
	}

	return aFiles.GetSize();
}
	size_t CEnvCanGribForecast::GetLatestHH(CHttpConnectionPtr& pConnection)const
	{
		ERMsg msg;

		size_t HH = NOT_INIT;

		vector<pair<CTRef, size_t>> latest;
		for (size_t h = 0; h < 24; h += 6)
		{
			string remotePath = GetRemoteFilePath(h, 0, (m_type == GT_HRDPS) ? "*P000-00.grib2":"*P000.grib2");

			CFileInfoVector fileListTmp;
			if (FindFiles(pConnection, remotePath, fileListTmp) && !fileListTmp.empty())
			{
				string fileTitle = GetFileName(fileListTmp.front().m_filePath);
				latest.push_back(make_pair(GetTRef(fileTitle), h));
			}
		}

		sort(latest.begin(), latest.end());
			
		if (!latest.empty())
			HH = latest.back().second;


		return HH;
	}
示例#8
0
void FindFiles(QString sDirectoryName,QStringList *pList,bool bSubDirs)
{
    QDir dir;
    dir.setPath(sDirectoryName);

    QFileInfoList fi=dir.entryInfoList();

    for(int i=0; i<fi.count(); i++)
    {
        if(fi.at(i).fileName()==".")
        {
            continue;
        }

        if(fi.at(i).fileName()=="..")
        {
            continue;
        }
        else if(fi.at(i).isFile())
        {
            pList->append(fi.at(i).absoluteFilePath());
        }

        if(fi.at(i).isDir()&&(bSubDirs))
        {
            FindFiles(fi.at(i).absoluteFilePath(),pList,bSubDirs);
        }
    }
}
示例#9
0
//-----------------------------------------------------------------------------
// Delete temporary files
//-----------------------------------------------------------------------------
void CScriptLib::DeleteTemporaryFiles( const char *pFileMask )
{
#if !defined( _X360 )
	const char *pEnv = getenv( "temp" );
	if ( !pEnv )
	{
		pEnv = getenv( "tmp" );
	}

	if ( pEnv )
	{
		char tempPath[MAX_PATH];
		strcpy( tempPath, pEnv );
		V_AppendSlash( tempPath, sizeof( tempPath ) );
		strcat( tempPath, pFileMask );

		CUtlVector<fileList_t> fileList;
		FindFiles( tempPath, false, fileList );
		for ( int i=0; i<fileList.Count(); i++ )
		{
			_unlink( fileList[i].fileName.String() );
		}
	}
#else
	AssertOnce( !"CScriptLib::DeleteTemporaryFiles:  Not avail on 360\n" );
#endif
}
示例#10
0
extern "C" bool ArchiveFolderW(HZIP hZip,WCHAR *sourceFolder,LPWSTR *fileMask,DWORD fileMaskCount,DWORD flags)
{
    bool r=false;
    if ((hZip) && (((ZIPCOMPRESSION *)hZip)->bHandleType == HT_COMPRESSOR) && (sourceFolder) && (fileMask) && (fileMaskCount))
    {
        CFFSTRUCT cs;
        cs.lpZipData=(ZIPCOMPRESSION *)hZip;
        cs.zip=((ZIPCOMPRESSION *)hZip)->hZip;
        if (cs.zip)
        {
            cs.filesCount=0;
            cs.cabPathOffset=lstrlenW(sourceFolder);

            if ((cs.cabPathOffset > 0) && (sourceFolder[cs.cabPathOffset-1] != '\\'))
                cs.cabPathOffset++;

            FindFiles(sourceFolder,fileMask,fileMaskCount,(flags & CFF_DELETE ? FFFLAG_DELETE : 0) | (flags & CFF_RECURSE ? FFFLAG_RECURSIVE : 0) | FFFLAG_SEARCH_FILES,CreateFromFolderProc,&cs,NULL,0,0);

            if ((cs.filesCount > 0))
                r=true;
        }
    }
    else
        ArchSetLastError(ARCH_INVALID_PARAMETER);
    return r;
}
// This method returns the the list of files we can use for the menu
// It will filter by episode and sort the list by number of slot
// It also takes care of the slotname resolution
std::vector<std::string> CSaveGameController::getSlotList()
{
    std::vector<std::string> filelist;
    std::string buf;

    //Get the list of ".ck?" files
    StateFileListFiller sfilelist;
    FindFiles(sfilelist, m_savedir, false, FM_REG);

    std::set<std::string>::iterator i;
    for( i=sfilelist.list.begin() ; i!=sfilelist.list.end() ; i++ )
    {
        buf = i->substr(i->size()-1);

        // Check if the file fits to this episode
        if(atoi(buf) == m_Episode)
        {
            Uint32 pos = getSlotNumber(*i)-1;
            buf = getSlotName(*i);

            if(pos+1 > filelist.size())
                filelist.resize(pos+1, "");

            filelist.at(pos) = buf;
        }
    }

    return filelist;
}
static void FindFiles(std::vector<std::string>& matches, const std::string& dir, const boost::regex &regexpattern, int flags)
{
    struct _finddata_t files;
    long hFile;

    if( (hFile = _findfirst( (dir + "*.*").c_str() , &files )) == -1L )
        return;

    do {
        // exclude hidden/system files
        if (files.name[0] != '.' && !(files.attrib & (_A_HIDDEN | _A_SYSTEM))) {
            // is it a file?
            if (!(files.attrib & _A_SUBDIR)) {
                if ((flags & FileSystem::ONLY_DIRS) == 0) {
                    if (boost::regex_match(files.name, regexpattern)) {
                        matches.push_back(dir + files.name);
                    }
                }
            }
            // or a directory?
            else {
                if (flags & FileSystem::INCLUDE_DIRS) {
                    if (boost::regex_match(files.name, regexpattern)) {
                        matches.push_back(dir + files.name + '\\');
                    }
                }
                if (flags & FileSystem::RECURSE) {
                    FindFiles(matches, dir + files.name + '\\', regexpattern, flags);
                }
            }
        }
    } while (_findnext( hFile, &files ) == 0);

    _findclose( hFile );
}
static void FindFiles(std::vector<std::string>& matches, const std::string& dir, const boost::regex &regexpattern, int flags)
{
	DIR* dp;
	struct dirent* ep;

	if (!(dp = opendir(dir.c_str())))
		return;

	while ((ep = readdir(dp))) {
		// exclude hidden files
		if (ep->d_name[0] != '.') {
			// is it a file? (we just treat sockets / pipes / fifos / character&block devices as files...)
			// (need to stat because d_type is DT_UNKNOWN on linux :-/)
			struct stat info;
			if (stat((dir + ep->d_name).c_str(), &info) == 0) {
				if (!S_ISDIR(info.st_mode)) {
					if (boost::regex_match(ep->d_name, regexpattern))
						matches.push_back(dir + ep->d_name);
				}
				// or a directory?
				else if (flags & FileSystem::RECURSE) {
					if ((flags & FileSystem::INCLUDE_DIRS) && boost::regex_match(ep->d_name, regexpattern))
						matches.push_back(dir + ep->d_name);
					FindFiles(matches, dir + ep->d_name + '/', regexpattern, flags);
				}
			}
		}
	}
	closedir(dp);
}
bool FSandboxPlatformFile::DeleteDirectory( const TCHAR* Path, bool Tree )
{
	if( Tree )
	{
		// Support code for removing a directory tree.
		bool Result = true;
		// Delete all files in the directory first
		FString Spec = FString( Path ) / TEXT( "*" );
		TArray<FString> List;
		FindFiles( List, *Spec, true, false );
		for( int32 FileIndex = 0; FileIndex < List.Num(); FileIndex++ )
		{
			FString Filename( FString( Path ) / List[ FileIndex ] );
			// Delete the file even if it's read-only
			if( LowerLevel->FileExists( *Filename ) )
			{
				LowerLevel->SetReadOnly( *Filename, false );
				if( !LowerLevel->DeleteFile( *Filename ) )
				{
					Result = false;
				}				
			}
			else
			{
				Result = false;
			}
		}
		// Clear out the list of found files and look for directories this time
		List.Empty();
		FindFiles( List, *Spec, false, true );
		for( int32 DirectoryIndex = 0; DirectoryIndex < List.Num(); DirectoryIndex++ )
		{
			if( !DeleteDirectory( *( FString( Path ) / List[ DirectoryIndex ] ), true ) )
			{
				Result = false;
			}
		}
		// The directory is empty now so it can be deleted
		return DeleteDirectory( Path, false ) && Result;
	}
	else
	{
		return LowerLevel->DeleteDirectory( Path ) || ( !LowerLevel->DirectoryExists( Path ) );
	}
}
示例#15
0
void FindFiles(LPWSTR path,const LPWSTR *fileMasks,DWORD fileMasksCount,DWORD flags,FINDFILEPROC findFileProc,void *data,HANDLE stopEvent,DWORD subfolderDelay,DWORD foundedDelay)
{
    WCHAR curPath[MAX_PATH];
    WIN32_FIND_DATAW wfd;
    HANDLE handle;

    if ((_PathCombine(curPath,path,L"*")) && ((handle=FindFirstFileW(curPath,&wfd)) != INVALID_HANDLE_VALUE))
    {
        do
        {
            if ((stopEvent != NULL) && (WaitForSingleObject(stopEvent,0) != WAIT_TIMEOUT))
                break;

            if (!IsDotsName(wfd.cFileName))
            {
                if (((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (flags & FFFLAG_SEARCH_FOLDERS)) || ((!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) && (flags & FFFLAG_SEARCH_FILES)))
                {
                    for (DWORD i=0; i < fileMasksCount; i++)
                    {
                        if (PathMatchSpecW(wfd.cFileName,fileMasks[i]) != FALSE)
                        {
                            if (!findFileProc(path,&wfd,data))
                                goto END;
                            if (flags & FFFLAG_DELETE)
                            {
                                WCHAR filePath[MAX_PATH];
                                if (_PathCombine(filePath,path,wfd.cFileName))
                                {
                                    SetFileAttributesW(filePath,FILE_ATTRIBUTE_NORMAL);
                                    DeleteFileW(filePath);
                                }
                            }
                            if (foundedDelay)
                                Sleep(foundedDelay);
                            break;
                        }
                    }
                }

                if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && flags & FFFLAG_RECURSIVE)
                {
                    if (_PathCombine(curPath,path,wfd.cFileName))
                    {
                        if (subfolderDelay)
                            Sleep(subfolderDelay);
                        FindFiles(curPath,fileMasks,fileMasksCount,flags,findFileProc,data,stopEvent,subfolderDelay,foundedDelay);
                    }
                }
            }
        }
        while (FindNextFileW(handle,&wfd) != FALSE);
END:    FindClose(handle);
    }
    return;
}
示例#16
0
std::list<std::string>* FindFiles(const std::string& searchPattern, bool recursive, const std::string& path)
{
    struct  _finddata_t  c_file;
    intptr_t  hFile;

	std::string searchPath;

	if (!path.empty()) 
		searchPath = path + "\\";

	std::list<std::string>* r = new std::list<std::string>();

	// search for directories to scan
	if (recursive)
	{
		hFile = _findfirst( (searchPath + "*").c_str(),  &c_file);
		while (hFile != -1)
		{
			if (strcmp(c_file.name, "..") &&  strcmp(c_file.name, "."))
			{
				if (c_file.attrib & _A_SUBDIR)
				{
					std::string ns = path + c_file.name;
					ns += "\\";
					
					std::list<std::string>* subdir = FindFiles(searchPattern, true, ns);
					r->insert(r->end(), subdir->begin(), subdir->end());
					delete subdir;
				}
			}

			if (_findnext(hFile, &c_file) != 0) 
			{
				_findclose(hFile);
				hFile = -1;
			}
		} 
	}

	// search files that match the pattern
	hFile = _findfirst( (searchPath + searchPattern).c_str(),  &c_file);
	while (hFile != -1)
	{
		if (!(c_file.attrib & _A_SUBDIR))
			r->push_back(searchPath + c_file.name);

		if (_findnext(hFile, &c_file) != 0) {
			_findclose(hFile);
			hFile = -1;
		}
    } 


	return r;
}
示例#17
0
CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories)
{
	// Reverse the loop order for speed?
	for (size_t j = 0; j < _rSearchStrings.size(); j++)
	{
		for (size_t i = 0; i < _rDirectories.size(); i++)
		{
			FindFiles(_rSearchStrings[j], _rDirectories[i]);
		}
	}
}
示例#18
0
CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories)
{
	// Reverse the loop order for speed?
	for (auto& _rSearchString : _rSearchStrings)
	{
		for (auto& _rDirectory : _rDirectories)
		{
			FindFiles(_rSearchString, _rDirectory);
		}
	}
}
示例#19
0
文件: digger.cpp 项目: mapme/poedit
Catalog *SourceDigger::Dig(const wxArrayString& paths,
                           const wxArrayString& excludePaths,
                           const wxArrayString& keywords,
                           const wxString& charset)
{
    ExtractorsDB db;
    db.Read(wxConfig::Get());

    m_progressInfo->UpdateMessage(_("Scanning files..."));

    wxArrayString *all_files = FindFiles(paths, excludePaths, db);
    if (all_files == NULL)
        return NULL;

    TempDirectory tmpdir;
    wxArrayString partials;

    for (size_t i = 0; i < db.Data.size(); i++)
    {
        if ( all_files[i].empty() )
            continue; // no files of this kind

        m_progressInfo->UpdateMessage(
            // TRANSLATORS: '%s' is replaced with the kind of the files (e.g. C++, PHP, ...)
            wxString::Format(_("Parsing %s files..."), db.Data[i].Name.c_str()));
        if (!DigFiles(tmpdir, partials, all_files[i], db.Data[i], keywords, charset))
        {
            delete[] all_files;
            return NULL;
        }
    }

    delete[] all_files;

    if ( partials.empty() )
        return NULL; // couldn't parse any source files

    wxString mergedFile = tmpdir.CreateFileName("merged.pot");

    if ( !ConcatCatalogs(partials, mergedFile) )
        return NULL;

    Catalog *c = new Catalog(mergedFile, Catalog::CreationFlag_IgnoreHeader);

    if ( !c->IsOk() )
    {
        wxLogError(_("Failed to load extracted catalog."));
        delete c;
        return NULL;
    }

    return c;
}
void FFileManagerGeneric::FindFilesRecursiveInternal( TArray<FString>& FileNames, const TCHAR* StartDirectory, const TCHAR* Filename, bool Files, bool Directories)
{
	FString CurrentSearch = FString(StartDirectory) / Filename;
	TArray<FString> Result;
	FindFiles(Result, *CurrentSearch, Files, Directories);

	for (int32 i=0; i<Result.Num(); i++)
	{
		FileNames.Add(FString(StartDirectory) / Result[i]);
	}

	TArray<FString> SubDirs;
	FString RecursiveDirSearch = FString(StartDirectory) / TEXT("*");
	FindFiles(SubDirs, *RecursiveDirSearch, false, true);

	for (int32 SubDirIdx=0; SubDirIdx<SubDirs.Num(); SubDirIdx++)
	{
		FString SubDir = FString(StartDirectory) / SubDirs[SubDirIdx];
		FindFilesRecursiveInternal(FileNames, *SubDir, Filename, Files, Directories);
	}
}
示例#21
0
void CGameGUIFileDialog::UpdateFiles()
{
	std::string sFile;
	if(m_piEDPath){sFile=m_piEDPath->GetText();}
	if(m_piLSFiles)
	{
		std::string sFilter=sFile+"*";
		std::set<std::string> sFiles;
		std::set<std::string>::iterator i;
		m_piLSFiles->Clear();

		FindFiles((sFilter).c_str(),eFindFilesMode_OnlyDirs,&sFiles);
		for(i=sFiles.begin();i!=sFiles.end();i++){m_piLSFiles->AddElement(*i);}
		sFiles.clear();
		FindFiles((sFilter).c_str(),eFindFilesMode_OnlyFiles,&sFiles);
		for(i=sFiles.begin();i!=sFiles.end();i++)
		{
			const char  *pFile=i->c_str();
			unsigned int nFile=i->length();
			if(m_vPatterns.size()==0)
			{
			  m_piLSFiles->AddElement(*i);
			}
			else
			{
			  for(unsigned int x=0;x<m_vPatterns.size();x++)
			  {
				unsigned int nPattern=m_vPatterns[x].length();
				const char  *pPattern=m_vPatterns[x].c_str();
				if(nFile>=nPattern &&
				  strcmp(pFile+nFile-nPattern,pPattern)==0)
				{
				  m_piLSFiles->AddElement(*i);
				  break;
				}
			  }
			}
		}
	}
}
void AddMissionsToTree(char *path, GtkWidget *tree, int is_parent) {
	glob_t *search;
	unsigned int length;
	int count, max;
	char *file, *filename;
	GtkWidget *subtree, *item;

	// First we check for sub directories. stick them at the top
	// For some reason, glob(,,GLOB_ONLYDIR,) doesn't seem to only match directories,
	// so FindDirs() currently returns everything. Check the last char for a /
	// That will be the directory.

	search = FindDirs(path);
	max = search->gl_pathc - 1;	// search->gl_pathc is a uint. If there's no files, it's 0.
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] != SEPERATOR) { continue; }	// Verify it's a directory and not a file

		filename = strdup(file);
		filename = StripPath(filename);
		if (strcmp("CVS", filename) == 0) { continue; }	// Don't need to display this directory

		item = AddItem(tree, filename, "dir");

		subtree = gtk_tree_new();
		gtk_signal_connect(GTK_OBJECT(subtree), "select_child", GTK_SIGNAL_FUNC(cb_select_child), subtree);
		gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child", GTK_SIGNAL_FUNC(cb_unselect_child), subtree);

		gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE);
		gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM);
		gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);		

		AddMissionsToTree(file, subtree, 0);

	}

	search = FindFiles(path, EXT_MISSION);
	max = search->gl_pathc - 1;
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] == SEPERATOR) { continue; }

		filename = strdup(file);
		filename = StripPath(filename);
		StripExtension(filename);

		AddItem(tree, filename, file);
	}
	return;
}
示例#23
0
CatalogPtr SourceDigger::Dig(const wxArrayString& paths,
                             const wxArrayString& excludePaths,
                             const wxArrayString& keywords,
                             const wxString& charset,
                             UpdateResultReason& reason)
{
    ExtractorsDB db;
    db.Read(wxConfig::Get());

    m_progressInfo->UpdateMessage(_("Scanning files..."));

    wxArrayString *all_files = FindFiles(paths, PathsToMatch(excludePaths), db);
    if (all_files == nullptr)
    {
        reason = UpdateResultReason::NoSourcesFound;
        return nullptr;
    }

    TempDirectory tmpdir;
    wxArrayString partials;

    for (size_t i = 0; i < db.Data.size(); i++)
    {
        if ( all_files[i].empty() )
            continue; // no files of this kind

        m_progressInfo->UpdateMessage(
            // TRANSLATORS: '%s' is replaced with the kind of the files (e.g. C++, PHP, ...)
            wxString::Format(_("Parsing %s files..."), db.Data[i].Name.c_str()));
        if (!DigFiles(tmpdir, partials, all_files[i], db.Data[i], keywords, charset))
        {
            delete[] all_files;
            return nullptr;
        }
    }

    delete[] all_files;

    wxString mergedFile;
    if ( !ConcatCatalogs(partials, tmpdir, &mergedFile) )
        return nullptr; // couldn't parse any source files

    CatalogPtr c = std::make_shared<Catalog>(mergedFile, Catalog::CreationFlag_IgnoreHeader);

    if ( !c->IsOk() )
    {
        wxLogError(_("Failed to load extracted catalog."));
        return nullptr;
    }

    return c;
}
示例#24
0
// Load the list of files
int FileList::Load(const char *inputPath)
{
	if(inputPath == NULL)
		return -1;

	const char *cur = inputPath;

	// Iterate through all comma separated items specified in the path
	while(*cur)
	{
		std::string item;

		// Get next item from the list
		cur = Str::GetNextInList(cur, item);

		if(item.empty())
			return 0;

		// Check whether the item points to an existing directory
		bool isDir = File::IsDirectory(item.c_str());

		std::string dir;
		std::string file;

		// If item is a directory, add *.* for files
		if(isDir)
		{
			dir = item;
			file = "*.*";
		}
		else
		{
			// Split directory and file parts
			File::SplitDirectoryAndFile(item.c_str(), dir, file);
		}

		std::list<std::string> dirs;

		// Directory may contain a wildcard, extend it
		GetDirectoriesByWildcard(dir.c_str(), dirs);

		// Find files, the directory list may grow(!) as new sub-directories can be found
		for(std::list<std::string>::iterator i = dirs.begin(); i != dirs.end(); i++)
		{
			// Find files in the specified directory matching the file wildcard
			FindFiles(*i, file, dirs, _files); 
		}

	}

	return 0;
}
void CGameLauncher::setupDosExecDialog()
{
    const std::string dataDir = getDirectory( m_chosenGame );

    // TODO: fetch the List of available patch files
    // Get the list of ".pat" files
    DosExecListFiller dosExecList;
    FindFiles(dosExecList, dataDir, false, FM_REG);

    if( dosExecList.list.empty() )
    {
        mExecFilename = "";
        mDoneExecSelection=true;
        return;
    }

    // If the there are not at least 2 mods to select, do not create the patch selection dialog
    if( dosExecList.list.size() == 1 )
    {
        mExecFilename = *(dosExecList.list.begin());
        mDoneExecSelection=true;
        return;
    }

    mpDosExecDialog.reset(new CGUIDialog(GsRect<float>(0.1f, 0.1f, 0.8f, 0.85f), CGUIDialog::EXPAND)),
    mpDosExecDialog->initEmptyBackground();


    if(!mDosExecStrVec.empty())
        mDosExecStrVec.clear();

    mpDosExecSelList = new CGUITextSelectionList();


    for( auto &elem : dosExecList.list )
    {
        const std::string dirname = GetDirName(elem);
        std::string name = elem.substr(dirname.size()+1);
        mDosExecStrVec.push_back(elem);
        mpDosExecSelList->addText(name);
    }

    mpDosExecSelList->setConfirmButtonEvent(new GMDosExecSelected());
    mpDosExecSelList->setBackButtonEvent(new GMQuit());

    mpDosExecDialog->addControl(new CGUIText("Choose your executable:"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
    mpDosExecDialog->addControl(mpDosExecSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.87f));


    mpDosExecDialog->addControl(new GsButton( "Start >", new GMDosExecSelected() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );
}
示例#26
0
文件: cunit.c 项目: asu88/SOT
int 
main(int argc, char *argv[])
{
	
	argc--;
	argv++;
	char* arry[MAXFILES];
	int nfiles;
	int i;
	if (argc==1){
		if (strcmp(argv[0],"-c")==0){
			nfiles=FindFiles(PWD, arry, OUT);
			//printf("Borrar %d ficheros .out\n", nfiles);
			for(i=0; i<nfiles; i++){
				unlink(arry[i]);
			}
			nfiles=FindFiles(PWD, arry, OK);
			//printf("Borrar %d ficheros .ok\n", nfiles);
			for(i=0; i<nfiles; i++){
				unlink(arry[i]);
			}
			exit(EXIT_SUCCESS);
		}
	}
	nfiles=FindFiles(PWD, arry, TST);
	//char* str=getenv("PATH");
	//int nargs=mytokenizedospuntos(str, listcommand);
	if(nfiles<0){
		printf("No hay ningun fichero .tst\n");
		exit(EXIT_SUCCESS);
	}
	for(i=0; i<nfiles; i++){
		forky_fichs(arry[i]);
	}
	exit(EXIT_SUCCESS);
}
示例#27
0
fsInternetResult fsInternetFileListMgr::GetList(LPCSTR pszUrl, LPCSTR pszUser, LPCSTR pszPassword)
{
	if (IsRunning ())
		return IR_S_FALSE;

	if (pszUser)
	{
		
		if (m_strUser != pszUser || m_strPassword != pszPassword)
		{
			
			Free ();
			m_bConnected = FALSE;	
		}
	}

	
	if (m_bConnected == FALSE && m_server.IsFtpServer ())
		Free ();	

	
	int iIndex = FindFiles (pszUrl);
	if (iIndex == -1)
	{
		
		m_bAbort = FALSE;
		_strUrl = pszUrl;
		_strUser = pszUser;
		_strPassword = pszPassword;
		Start ();
	}
	else
	{
		m_files = m_vFiles [iIndex];
		m_bCurPathIsRoot = strcmp (GetCurrentPath (), "/") == 0 || strcmp (GetCurrentPath (), "\\") == 0;
		m_lastError = IR_SUCCESS;
		m_bConnected = TRUE;
		Event (FLME_DONE_FROM_CACHE);
	}

	return IR_SUCCESS;
}
示例#28
0
void CGameGUIFileDialog::AutoComplete()
{
	std::string sFile;
	if(m_piEDPath){sFile=m_piEDPath->GetText();}
	
	std::string sFilter=sFile+"*";
	std::set<std::string> sCandidateFiles;
	std::set<std::string> sFiles;
	std::set<std::string>::iterator i;
	FindFiles(sFilter.c_str(),eFindFilesMode_DirsAndFiles,&sFiles);
	for(i=sFiles.begin();i!=sFiles.end();i++)
	{
	  const char *pEditFile=sFile.c_str();
	  const char *pListFile=i->c_str();
	  if(strncmp(pListFile,pEditFile,sFile.length())!=0){continue;}
	  sCandidateFiles.insert(*i);
	}
	if(sCandidateFiles.size())
	{
	  while(true)
	  {
		int nPos=sFile.length();
		bool bFinished=true;
		unsigned char nChar=sCandidateFiles.begin()->c_str()[nPos];
		if(nChar==0){break;}
		for(i=sCandidateFiles.begin();i!=sCandidateFiles.end();i++)
		{
		  if(i->c_str()[nPos]!=nChar){bFinished=false;break;}
		}
		if(!bFinished){break;}
		sFile+=nChar;
	  }
	}
	if(m_piEDPath)
	{
	  std::string sNormalized=NormalizePath(sFile);
	  m_piEDPath->SetText(sNormalized);
	  m_piEDPath->SetCursor(sNormalized.length());
	  
	  UpdateFiles();
	}
}
示例#29
0
//
// ZapFolder
//
// Moves the entire content of the given directory up one level and then "zaps" the directory.
//
// @param p_hParentWnd Handle of parent window for dialog boxes.
//                     If this is set to 0, we will not show any UI.
// @param p_Folder Folder path.
// @param p_rYesToAll true if user chose to answer "Yes" to all confirmations.
// @return Result code.
//
HRESULT CLevelZapContextMenuExt::ZapFolder(const HWND p_hParentWnd,
										   CString p_Folder,
										   bool& p_rYesToAll) const {
	CString folderName = Util::PathFindFolderName(p_Folder);

	// Ask for confirmation.
	CString confirmMsg1(MAKEINTRESOURCE(IDS_ZAP_CONFIRM_MESSAGE_1));
	CString confirmMsg2(MAKEINTRESOURCE(IDS_ZAP_CONFIRM_MESSAGE_2));
	CString confirmMsgComplete = confirmMsg1 + folderName + confirmMsg2;
	CString confirmMsgOld1(MAKEINTRESOURCE(IDS_ZAP_CONFIRM_MESSAGE_OLD_1));
	CString confirmMsgOld2(MAKEINTRESOURCE(IDS_ZAP_CONFIRM_MESSAGE_OLD_2));
	CString confirmMsgCompleteOld = confirmMsgOld1 + folderName + confirmMsgOld2;
	if (!p_rYesToAll && !m_bRecursive)
		if (!Dialog::doModal(p_hParentWnd, Util::GetVersionEx2()>=6?confirmMsgComplete.GetBuffer():confirmMsgCompleteOld.GetBuffer())) return E_ABORT;

	// Check for name collission
	BOOL bRename = Util::PathFindFile(p_Folder, Util::PathFindFolderName(p_Folder), m_bRecursive);
	CString _p_Folder(p_Folder);
	if (bRename)
		p_Folder.Empty();
	if (bRename) {
		if (!SUCCEEDED(Util::MoveFolderEx(_p_Folder, p_Folder)))
			return E_FAIL;
	}

	// create list of files to move
	CString szlFrom, szlTo;
	if (!SUCCEEDED(FindFiles(p_hParentWnd, Util::PathFindPreviousComponent(p_Folder), p_Folder, szlFrom, szlTo))) {
		if (bRename)
			Util::MoveFolderEx(p_Folder, _p_Folder);
		return E_FAIL;
	}

	// move files and don't leave an empty folder
	if (SUCCEEDED(MoveFile(p_hParentWnd, szlFrom, szlTo)) || Util::PathIsDirectoryEmptyEx(p_Folder)) {
		// Delete source directory
		DeleteFolder(p_hParentWnd, p_Folder);
		return S_OK;
	} else
		return E_FAIL;
	return S_OK;
}
示例#30
0
bool CSADirRead::GetFiles(const char *pFilemask, bool bIncludeFilesInFileList, bool bIncludeFoldersInFileList)
{
	// get the files in each of our directories
	for (int it = 0;it!=m_dirs.size(); it++) 
	{
		CCOMString curDir = m_dirs[it].m_sName;

      // sanity check
		if (curDir.IsEmpty())
		{
			continue;
		}
		
		if (!FindFiles(curDir, pFilemask, bIncludeFilesInFileList, bIncludeFoldersInFileList))
		{
			return false;
		}
	}

	return true;
}