static void UpdateGroupItems(std::vector<CProject::Group>& m_Groups) { std::vector<std::string> folderlist = GetFolderList("*"); for (unsigned int i = 0; i < folderlist.size(); i++) { if (!strcmp(folderlist[i].c_str(), ".") || !strcmp(folderlist[i].c_str(), "..")) { continue; } // insert files into that folder char directory[MAX_PATH] = {0}; GetCurrentDirectory(MAX_PATH, directory); SetCurrentDirectory(folderlist[i].c_str()); std::vector<std::string> filelist = GetFileList("*"); if (1) { CProject::Group current; current.FolderName = folderlist[i]; current.Files = GetFileList("*"); m_Groups.push_back(current); } filelist.clear(); if (GetFolderList("*").size() > 0) { UpdateGroupItems(m_Groups); } SetCurrentDirectory(directory); } }
void GUIFileSelector::SetPageFocus(int inFocus) { if (inFocus) { std::string value; DataManager::GetValue(mPathVar, value); if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) { GetFileList(DataManager::GetCurrentStoragePath()); DataManager::SetValue(mPathVar, DataManager::GetCurrentStoragePath()); } } }
void GUIFileSelector::SetPageFocus(int inFocus) { if (inFocus) { std::string value; DataManager::GetValue(mPathVar, value); // This is because some installers will unmount the sdcard ensure_path_mounted("/sdcard"); if (GetFileList(value) != 0 && (mShowNavFolders != 0 || mShowFiles != 0)) GetFileList("/sdcard"); } }
void GetFileListRecursive(std::string dir, StringList& files, bool withQueriedDir /* = false */) { std::stack<std::string> stk; if(withQueriedDir) { stk.push(dir); while(stk.size()) { dir = stk.top(); stk.pop(); MakeSlashTerminated(dir); StringList li; GetFileList(dir.c_str(), li); for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it) files.push_back(dir + *it); li.clear(); GetDirList(dir.c_str(), li, true); for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it) stk.push(dir + *it); } } else { std::string topdir = dir; MakeSlashTerminated(topdir); stk.push(""); while(stk.size()) { dir = stk.top(); stk.pop(); MakeSlashTerminated(dir); StringList li; dir = topdir + dir; GetFileList(dir.c_str(), li); for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it) files.push_back(dir + *it); li.clear(); GetDirList(dir.c_str(), li, true); for(std::deque<std::string>::iterator it = li.begin(); it != li.end(); ++it) stk.push(dir + *it); } } }
bool wxGISDataset::Delete(int iLayer, ITrackCancel* const pTrackCancel) { wxCriticalSectionLocker locker(m_CritSect); Close(); if(!DeleteFile(m_sPath)) return false; char** papszFileList = GetFileList(); if(papszFileList) { IProgressor* pProgressor(NULL); if(pTrackCancel) { pProgressor = pTrackCancel->GetProgressor(); if(pProgressor) pProgressor->SetRange(CSLCount(papszFileList)); } for(int i = 0; papszFileList[i] != NULL; ++i ) { DeleteFile(papszFileList[i]); if(pProgressor) pProgressor->SetValue(i); } CSLDestroy( papszFileList ); } return true; }
void delete_fn(file_info *finfo, const char *name, void *state) { int rc; char temp[512]; char s[1024]; char FileName[128]; DWORD gle; sprintf(FileName, "Thread_%05d.log", ProcessNumber); if (finfo->mode & aDIR) { char s2[1024]; sprintf(s2, "%s\\*", name); GetFileList(s2, delete_fn, NULL); sprintf(s, "%s", &name[strlen(AfsLocker)]); nb_rmdir(s); } else { rc = DeleteFile(name); gle = GetLastError(); if (!rc) { LeaveThread(0, "", CMD_UNLINK); sprintf(temp, "FILE: DeleteFile %s failed GLE(0x%x)\n", name, gle); if (verbose) printf("%s", temp); LogMessage(ProcessNumber, HostName, FileName, temp, LogID); return; } } return; }
int nb_findfirst(char *mask) { int rc; char FileName[128]; char NewMask[512]; char temp[512]; if (strstr(mask, "<.JNK")) return(0); sprintf(FileName, "Thread_%05d.log", ProcessNumber); strcpy(NewMask, AfsLocker); strcat(NewMask, mask); StartFirstTimer(); rc = GetFileList(NewMask, (void *)find_fn, NULL); if (!rc) { EndFirstTimer(CMD_FIND_FIRST, 0); sprintf(temp, "File: findfirst cannot find for %s\n", mask); if (verbose) printf("%s", temp); LeaveThread(1, temp, CMD_FIND_FIRST); LogMessage(ProcessNumber, HostName, FileName, temp, LogID); return(-1); } EndFirstTimer(CMD_FIND_FIRST, 1); return(0); }
bool MemoryCardDriverThreaded_Linux::USBStorageDevicesChanged() { RString sThisDevices; /* If a device is removed and reinserted, the inode of the /sys/block entry * will change. */ RString sDevicePath = "/sys/block/"; vector<RString> asDevices; GetFileList( sDevicePath, asDevices ); for( unsigned i = 0; i < asDevices.size(); ++i ) { struct stat buf; if( stat( sDevicePath + asDevices[i], &buf ) == -1 ) continue; // XXX warn sThisDevices += ssprintf( "%i,", (int) buf.st_ino ); } bool bChanged = sThisDevices != m_sLastDevices; m_sLastDevices = sThisDevices; if( bChanged ) LOG->Trace( "Change in USB storage devices detected." ); return bChanged; }
size_t GetFileList( const char *_path, std::vector<std::string> &list, bool recur ) { size_t s = list.size(); char path[MAX_PATH], n[128]; strcpy( path, _path ); int pos = SplitFileName( path ); path[pos] = '\0'; strcpy( n, &path[pos+1] ); WIN32_FIND_DATA fdata; HANDLE h = FindFirstFile( _path, &fdata ); if( h == INVALID_HANDLE_VALUE ) return list.size() - s; do { char p[MAX_PATH]; sprintf( p, "%s\\%s", path, fdata.cFileName ); list.push_back( p ); if( recur && fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && strcmp( "..", fdata.cFileName ) && strcmp( ".", fdata.cFileName ) ) { char p[MAX_PATH]; sprintf( p, "%s\\%s\\%s", path, fdata.cFileName, n ); GetFileList( p, list, recur ); } } while( FindNextFile( h, &fdata ) ); FindClose( h ); return list.size() - s; }
GUnitViewer* GUnitViewer::CreateUnitViewer(GnList<GUserHaveItem::Item>& cUnitItems) { GetGameState()->SetGameScale( 0.7f ); GUnitViewer* thisObject = GnNew GUnitViewer(); GnListIterator<GUserHaveItem::Item> iter = cUnitItems.GetIterator(); gtint itemCount = 0; while( iter.Valid() ) { guint32 unitIndex = iter.Item().mIndex; gchar idName[16] = { 0, }; GetFileList()->GetForcesFileName( (gtuint)unitIndex, idName, sizeof( idName ) ); GForcesController* controller = GForcesController::Create( idName, 1 ); if( controller ) { GnVector2 pos( 340.0f, 150.0f ); if( itemCount == 0 ) pos.x -= 10.0f; controller->SetPosition( pos ); controller->GetMesh()->SetVisible( false ); thisObject->AddMeshToParentNode( controller->GetMesh() ); controller->GetActor()->SetTargetAnimation( GAction::ANI_ATTACK ); thisObject->AddActorCtlr( unitIndex, controller ); } iter.Forth(); ++itemCount; } GetGameState()->SetGameScale( 1.0f ); return thisObject; }
void JVMGetSourceFileList::ScanDirectory ( const JCharacter* path ) { JDirInfo* info; if (!JDirInfo::Create(path, &info)) { return; } JXFileListTable* table = (GetFileList())->GetTable(); const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& e = info->GetEntry(i); if (e.GetType() == JDirEntry::kFile) { const CBTextFileType fileType = (CMGetPrefsManager())->GetFileType(e.GetName()); if (fileType == kCBJavaSourceFT) { table->AddFile(e.GetFullName()); } } else if (e.GetType() == JDirEntry::kDir) { ScanDirectory(e.GetFullName()); } } delete info; }
void CEGASprit::DerivePlayerSprites( const int id, std::vector<GsSprite> &sprites ) { for(Uint16 s=0 ; s<gGraphics.getSpriteVec(id).size() ; s++) { GsSprite &Sprite = gGraphics.getSprite(id,s); Sprite.optimizeSurface(); } // Try to load player sprites here! std::set<std::string> filelist; FileListAdder fileListAdder; std::string gfxpath = JoinPaths(m_gamepath, "gfx"); GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG); const std::string spriteFn = "sprite"+itoa(id)+"_"; FilterFilelist(filelist, spriteFn); std::set<std::string>::iterator it = filelist.begin(); for( ; it != filelist.end() ; it++ ) { std::string name = *it; const int num = getRessourceID(name, spriteFn); GsSprite &Sprite = gGraphics.getSprite(id,num); std::string filename = getResourceFilename("gfx/"+name, m_gamepath, false, true); Sprite.loadHQSprite(filename); Sprite.applyTransparency(); } }
int GUIFileSelector::NotifyVarChange(std::string varName, std::string value) { if (varName.empty()) { // Always clear the data variable so we know to use it DataManager::SetValue(mVariable, ""); } if (!mHeaderIsStatic) { std::string newValue = gui_parse_text(mHeaderText); if (mLastValue != newValue) { mLastValue = newValue; mStart = 0; scrollingY = 0; scrollingSpeed = 0; mUpdate = 1; } } if (varName == mPathVar || varName == mSortVariable) { DataManager::GetValue(mPathVar, value); // sometimes the value will be the sort order instead of the path, so we read the path everytime DataManager::GetValue(mSortVariable, mSortOrder); mStart = 0; scrollingY = 0; scrollingSpeed = 0; GetFileList(value); mUpdate = 1; return 0; } return 0; }
bool CSVFile::GetPathFromSettings(const TCHAR *lr2Path, TCHAR *out) { // first of all, get setting and replace path std::wstring keyval; bool foundSetting = false; if (CSVSettings::GetPathValue(lr2Path, keyval)) { std::wstring wpath = lr2Path; int p = wpath.find(L'*'); if (p != std::wstring::npos) { wpath.replace(p, 1, keyval); if (boost::filesystem::exists(wpath)) { wcscpy(out, wpath.c_str()); foundSetting = true; } } } if (foundSetting) return true; // when no setting found, then get default value std::vector<std::wstring> files; GetFileList(lr2Path, files); if (files.size() == 0) { return false; } else if (files.size() == 1) { wcscpy(out, files[0].c_str()); return true; } else { // index 0 is default wcscpy(out, files[0].c_str()); return true; } }
//----------------------------------------------------------------------------- // Purpose: Generate a list of file matching mask //----------------------------------------------------------------------------- int CScriptLib::FindFiles( char* pFileMask, bool bRecurse, CUtlVector<fileList_t> &fileList ) { char dirPath[MAX_PATH]; char pattern[MAX_PATH]; char extension[MAX_PATH]; // get path only strcpy( dirPath, pFileMask ); V_StripFilename( dirPath ); // get pattern only V_FileBase( pFileMask, pattern, sizeof( pattern ) ); V_ExtractFileExtension( pFileMask, extension, sizeof( extension ) ); if ( extension[0] ) { strcat( pattern, "." ); strcat( pattern, extension ); } if ( !bRecurse ) { GetFileList( dirPath, pattern, fileList ); } else { // recurse and get the tree CUtlVector< fileList_t > tempList; CUtlVector< CUtlString > dirList; RecurseFileTree_r( dirPath, 0, dirList ); for ( int i=0; i<dirList.Count(); i++ ) { // iterate each directory found tempList.Purge(); tempList.EnsureCapacity( dirList.Count() ); GetFileList( dirList[i].String(), pattern, tempList ); int start = fileList.AddMultipleToTail( tempList.Count() ); for ( int j=0; j<tempList.Count(); j++ ) { fileList[start+j] = tempList[j]; } } } return fileList.Count(); }
int main( int argc, char ** argv ) { int nLibIndex = ParseArgs( argc, argv ); if( nLibIndex == 0 ) return -1; if( g_fDiag ) Diags( argc, argv ); Logger logger; GetLinuxPwd(); for( ; nLibIndex < argc; nLibIndex++ ) { StringList files = GetFileList( argv[nLibIndex] ); for( StringList::const_iterator it=files.begin(); it!=files.end(); ++it ) { std::string library = *it; std::cout << "Loading Library: " << library << std::endl; DllHandle hModule = LOAD_LIBRARY( library.c_str() ); DLERROR_CHECK; if( !hModule ) { std::cout<<"ERROR: Failed to load "<< *it << std::endl; std::cout.flush(); continue; } RunAllFn pRunAll = (RunAllFn)GET_PROC_ADDRESS( hModule, "RunAll" ); if( pRunAll == NULL ) { std::cerr << std::endl << "Function RunAll() not found in library " << library << "!" << std::endl; FREE_LIBRARY( hModule ); continue; } pRunAll( &logger, g_configFileName.c_str() ); FREE_LIBRARY( hModule ); } // next library } // next arg if( g_fCSV ) { try { std::ofstream log(g_logPath.c_str()); GenerateReportCSV( logger, log, g_fNoHeader ); } catch(...) { std::cerr << "Error writing log file " << g_logPath << "!" << std::endl; } } std::cout << std::endl; }
//开始分析 bool AnalyseClassCallRelation::Analyse() { //是否获取读取clw文件 //不从clw文件获取类与资源的关系 /* if ( m_vRelationData.empty() ) { GetClwFile(); } */ //获取文件列表 vector<ClassSource> vFileList; if (! GetFileList(vFileList)) { return false; } //先分配7K的内存用来存放文件 GetMemory(40*1024); //对文件列表里文件做处理 vector<string> vClass; vector<ClassSource>::iterator iter = vFileList.begin(); FILE *fp; fp = fopen("Test.data", "w"); while (iter != vFileList.end() ) { //获取头文件信息, 得出该文件需要分析的类 vClass.clear(); string strFileName = iter->strName + ".h"; DWORD dwFileStartTime = GetTickCount(); if (! GetClassFromHeader(strFileName, vClass) ) { ++ iter ; continue; } //判断是否为clw中的类 vector<string>::iterator strIter = vClass.begin(); while (strIter != vClass.end() ) { // if (IsClwClass(*strIter)) { //是clw中的类,分析, 传入类实现文件 头文件和实现文件只有后缀区别 Analyse(iter->strName, *strIter); } ++ strIter; } ++ iter ; DWORD dwFileEndTime = GetTickCount(); fprintf(fp, "%s %d\n", strFileName.c_str(), dwFileEndTime-dwFileStartTime); } fclose(fp); return true; }
int DCppTemplate::GetBlockSequenceByFile(const char *fileName) { vector<string> fileNameList; fileNameList = GetFileList(); for(int i=0 ; i < fileNameList.size() ; i++) { if (fileNameList[i] == fileName) return i; } return -1; }
void CLogDelOperate::DeleteBackupLogFile(const string & strLogPath, unsigned int keep_days) { vector<string> vFileInfoList; int count = 0; GetFileList(strLogPath, string(".log"), keep_days, vFileInfoList, 100, count); for(size_t i = 0; i < vFileInfoList.size(); i++) { ::remove(vFileInfoList[i].c_str()); } }
void CRapiFileDialog::OnFileListColClick( wxListEvent &event ) { if(event.GetColumn()==m_nSortColumn) { m_bSortDirection=!m_bSortDirection; } else { m_nSortColumn=event.GetColumn(); } GetFileList()->SortItems(ListCompareFunction,(long)this); }
bool DCppTemplate::CheckContain() { if (GetSourceBlockNum() <= 0) return false; if (m_HaveFileNameFlag) { if (GetFileList().size() != GetSourceBlockNum()) return false; } return true; }
//--------------------------------------------------------------------------- bool __fastcall TRelDirSearchForm::GetFileList(AnsiString folder) { try { GetFileList(folder, folder.Length()); } catch(...) { return false; } return true; }
/************************************************************** * * Entry: * * sockfd - the socket to send the file list to. * * * * Exit: * * n/a * * * * Purpose: * * Sends the server's directory list to the client * * * ***************************************************************/ void SendFileListToServer(int sockfd) { char fileList[FILELISTLENGTH]; bzero(fileList, FILELISTLENGTH); GetFileList(fileList); int sendSize = FILELISTLENGTH; if (send(sockfd, fileList, sendSize, 0) < 0) { printf("Error: Failed to send directory list.\n"); } }
//--------------------------------------------------------------------------- void __fastcall TRelDirSearchForm::GetFileList(AnsiString path, int baselen) { TSearchRec r; int done; done=FindFirst(path + "*.*" ,faAnyFile, r); try { while(!done) { if(r.FindData.cFileName[0]!='.') { if(! (r.Attr & faDirectory)) { // a file AnsiString name = AnsiString(path.c_str()+ baselen) + r.FindData.cFileName; FileList->Add(name); CurrentLabel->Caption = name; AnsiString fileext = ExtractFileExt(r.FindData.cFileName); ExtList->Add(fileext); // message processing Application->ProcessMessages(); if(Aborted) { throw EAbort("Aborted"); // raise an aborting exception } } else { // a directory if(r.Name != "." && r.Name != ".." && !(r.Name == "CVS" && FileExists(path + AnsiString("CVS\\Repository")))) // ignoring CVS meta-data directory { GetFileList(path + r.FindData.cFileName+ AnsiString("\\"), baselen); } } } done=FindNext(r); } } catch(Exception &e) { FindClose(r); throw Exception(e); } FindClose(r); }
void CRapiFileDialog::OnFileListItemSelected( wxListEvent &event ) { long data=GetFileList()->GetItemData(event.GetIndex()); if(data<0 || data>=(long)m_currentpaths.size()) { return; } if(m_currentpaths[data].Last()!=wxT('\\')) { SetPathName(m_currentpaths[data]); } }
bool GFarAttack::CreateAttackMesh(gtuint uiIndex) { gstring fullName; if( GetFileList()->GetFullEffectName( uiIndex, fullName ) == false ) return false; mpsAttackMesh = Gn2DMeshObject::CreateFullPath( fullName.c_str(), true ); mOriginalAttackRect.left = 0.0f; mOriginalAttackRect.top = 0.0f; mOriginalAttackRect.right = mpsAttackMesh->GetSize().x; mOriginalAttackRect.bottom = mpsAttackMesh->GetSize().y; SetPosition( GnVector2(0.0f, 0.0f) ); return true; }
void forEachFile(const char* basedir, const char* extension, const FileNameCallback& callback, std::size_t depth) { GSList* list = GetFileList(basedir, extension, depth); for(GSList* i = list; i != 0; i = g_slist_next(i)) { const char* name = reinterpret_cast<const char*>((*i).data); if(extension_equal(path_get_extension(name), extension)) { callback(name); } } ClearFileDirList(&list); }
void CLogDelOperate::GetFileList(const string& strFullPath, const string& strFileType, unsigned int keep_Time, vector<string> & vFileInfoList, int nMaxFileNum, int & nCurrentCount) { string strCondition = strFullPath + "\\*.log"; struct _finddata_t file_data; intptr_t hFile; hFile = ::_findfirst(strCondition.c_str(), &file_data); if(-1L != hFile ) { do{ printf("GetFileList(%s), file :%s, attrib=%d.current count=%d\n", strFullPath.c_str(), file_data.name, file_data.attrib, nCurrentCount); if(_A_SUBDIR != file_data.attrib) //如果不是目录文件,就将该文件的相关信息放入lstFilesList中 { if(strstr(file_data.name, strFileType.c_str()) == NULL) continue; string strFileName = strFullPath + "/" + file_data.name; time_t writeTime = file_data.time_write; time_t keepTime; keepTime = time(NULL) - keep_Time*24*60*60; //按天数保存,保存日志期限,换算成秒 if(writeTime < keepTime) { //超过保留时间,需要删除 //logger.info("[file delete] need remove file(%s),current count=%d\n", strFileName.c_str(), nCurrentCount); vFileInfoList.push_back(strFileName); if(++nCurrentCount >= nMaxFileNum) { ::_findclose(hFile); nCurrentCount = 0; //返回前计数器要清空! return; } } } else //如果是目录文件,就递归调用GetFileList函数,读取目录中的文件 { if(file_data.name[0] == '.') continue; //每个目录下面都有两个默认目录就是..和.分别表示上一级目录和当前目录 string strSubPath = strFullPath + "/" + file_data.name; GetFileList(strSubPath, strFileType, keep_Time, vFileInfoList, nMaxFileNum, nCurrentCount); } } while(0 == _findnext(hFile, &file_data)); ::_findclose(hFile); nCurrentCount = 0;//返回前计数器要清空! } }
void CRapiFileDialog::OnFileListItemActivated( wxListEvent &event ) { long data=GetFileList()->GetItemData(event.GetIndex()); if(data<0 || data>=(long)m_currentpaths.size()) { return; } bool bDone=m_currentpaths[data].Last()!=wxT('\\'); SetPathName(m_currentpaths[data]); if(bDone) { EndModal(wxID_OK); } }
void FileBrowser::DebugOut() { DebugMsg("FileBrowser","Listing %s",GetCurrentPath().c_str()); vector<string> folders = GetFolderList(); DebugMsg("FileBrowser","Folders : "); for(unsigned int x=0;x<folders.size();x++) { DebugMsg("FileBrowser","%s",folders.at(x).c_str()); } vector<string> files = GetFileList(); DebugMsg("FileBrowser","Files : "); for(unsigned int x=0;x<files.size();x++) { DebugMsg("FileBrowser","%s",files.at(x).c_str()); } }