inline void DoRecurse(TArchiveWriter& w, Stroka off) const { { TFileList fl; const char* name; const Stroka p = Path + off; fl.Fill(~p); while ((name = fl.Next())) { const Stroka fname = p + name; const Stroka rname = Prefix + off + name; Append(w, fname, rname); } } if (Recursive) { TDirsList dl; const char* name; const Stroka p = Path + off; dl.Fill(~p); while ((name = dl.Next())) { if (strcmp(name, ".") && strcmp(name, "..")) { DoRecurse(w, off + name + "/"); } } } }
void mtlrchApp::EvDropFiles (TDropInfo drop) { // Number of files dropped. int totalNumberOfFiles = drop.DragQueryFileCount(); TFileList* files = new TFileList; for (int i = 0; i < totalNumberOfFiles; i++) { // Tell DragQueryFile the file interested in (i) and the length of your buffer. int fileLength = drop.DragQueryFileNameLen(i) + 1; char *fileName = new char[fileLength]; drop.DragQueryFile(i, fileName, fileLength); // Getting the file dropped. The location is relative to your client coordinates, // and will have negative values if dropped in the non client parts of the window. // // DragQueryPoint copies that point where the file was dropped and returns whether // or not the point is in the client area. Regardless of whether or not the file // is dropped in the client or non-client area of the window, you will still receive // the file name. TPoint point; BOOL inClientArea = drop.DragQueryPoint(point); files->Add(new TFileDrop(fileName, point, inClientArea, this)); } // Open the files that were dropped. AddFiles(files); // Release the memory allocated for this handle with DragFinish. drop.DragFinish(); }
bool __fastcall TEditTiffForm::PrintFile(void) { //------------------------------------------------------------------------------- // Печатает файл tic.Filename и кладет его в tb->Images | // Если что не получилось, то выдает сообщение и возвращает false | //------------------------------------------------------------------------------- bool res; TFileList *ffl = new TFileList; String aFiln = ErasePathFromFiln(tic.Filename); ffl->Append("", tic.Filename, "", ""); String filn; int filn_n; char buf[50], path[300]; filn = CreateTempFiln(); Visible = false; res = SEnumMainForm->PrintFilesLoaded(filn.c_str(), ffl, 0, 0); delete ffl; Visible = true; if (!res) return false; res = tb->LoadTiff(filn); DeleteFile(filn); return true; }
// tests one by one touching each runtime modifiable source file // returns the number of errors - 0 if all passed. int RuntimeObjectSystem::TestBuildAllRuntimeSourceFiles( ITestBuildNotifier* callback, bool bTestFileTracking ) { if( m_pCompilerLogger ) { m_pCompilerLogger->LogInfo("TestBuildAllRuntimeSourceFiles Starting\n"); } ITestBuildNotifier* failCallbackLocal = callback; if( !failCallbackLocal ) { failCallbackLocal = this; } int numErrors = 0; size_t numFilesToBuild = 0; for( unsigned short proj = 0; proj < m_Projects.size( ); ++proj ) { numFilesToBuild += m_Projects[ proj ].m_RuntimeFileList.size( ); } if( 0 == numFilesToBuild ) { failCallbackLocal->TestBuildCallback( NULL, TESTBUILDRRESULT_NO_FILES_TO_BUILD ); } for( unsigned short proj = 0; proj < m_Projects.size(); ++proj ) { TFileList filesToTest = m_Projects[ proj ].m_RuntimeFileList; // m_RuntimeFileList could change if file content changes (new includes or source dependencies) so make copy to ensure iterators valid. for( TFileList::iterator it = filesToTest.begin(); it != filesToTest.end(); ++it ) { const Path& file = *it; if( file.Extension() != ".h" ) // exclude headers, use TestBuildAllRuntimeHeaders { int fileErrors = TestBuildFile( m_pCompilerLogger, this, file, failCallbackLocal, bTestFileTracking ); if( fileErrors < 0 ) { // this means exit, and the number of errors is -ve so remove, unless -0xD1E is the response (for no error die) if( fileErrors != -0xD1E ) { numErrors -= fileErrors; } return numErrors; } numErrors += fileErrors; } } } if( 0 == numErrors ) { if( m_pCompilerLogger ) { m_pCompilerLogger->LogInfo("All Tests Passed\n"); } } else { if( m_pCompilerLogger ) { m_pCompilerLogger->LogError("Tests Failed: %d\n", numErrors); } } return numErrors; }
FileMonitor::TFileList::iterator FileMonitor::GetWatchedFileEntry( const FileSystemUtils::Path& file, TFileList& fileList ) { TFileList::iterator fileIt = fileList.begin(); TFileList::iterator fileItEnd = fileList.end(); while (fileIt != fileItEnd && !ArePathsEqual(fileIt->file, file)) { fileIt++; } return fileIt; }
void CCRUDProcessor::ProcessFiles(TFileList &fileList, const char *pSourceDir, const char *pDestDir, bool bRecursive, CCRUDResults &results) { OutputResult("Processing File List.."); TFileList::iterator curFile = fileList.begin(); TDateTime timeBegin; timeBegin = timeBegin.CurrentDateTime(); results.m_iFilesFound = 0; results.m_iFilesCopied = 0; int nTopLevel = fileList.size(); ResetEvent(m_hStopEvent); while ((WaitForSingleObject(m_hStopEvent, 0) == WAIT_TIMEOUT) && (curFile != fileList.end())) { // Count this file ++results.m_iFilesFound; // Get the source file name string curFileName(pSourceDir); curFileName += '\\'; curFileName += *curFile; CleanPath(curFileName.begin()); // Look for new files in this file bool bSearchInFile = bRecursive || nTopLevel; if (!bSearchInFile || SearchForNewFiles(fileList, curFileName.begin())) { // Get the destination file name string destFileName(pDestDir); destFileName += '\\'; destFileName += *curFile; CleanPath(destFileName.begin()); // Copy it if it needs to be updated if (MaybeCopyFile(curFileName.begin(), destFileName.begin())) ++results.m_iFilesCopied; } if (nTopLevel) --nTopLevel; // Go to the next file in the list ++curFile; // Breathe Application->ProcessMessages(); } results.m_ProcessingTime = timeBegin.CurrentDateTime() - timeBegin; }
/** Save result of prediction to file */ void SavePredictions(const TFileList& file_list, const TLabels& labels, const string& prediction_file) { // Check that list of files and list of labels has equal size assert(file_list.size() == labels.size()); // Open 'prediction_file' for writing ofstream stream(prediction_file.c_str()); // Write file names and labels to stream for (size_t image_idx = 0; image_idx < file_list.size(); ++image_idx) stream << file_list[image_idx].first << " " << labels[image_idx] << endl; stream.close(); }
bool AddFileToList(TFileList &fileList, const char *pName) { for (TFileList::iterator curFile = fileList.begin(); curFile != fileList.end(); ++curFile) { if (stricmp(curFile->begin(), pName) == 0) return false; } // Ok, add it to the end.. fileList.push_back(pName); return true; }
//************************************************************************* void BeatDetectorApp::NextFile() { roto = 0; if(mTrack && mTrack->isPlaying()) { mTrack->enablePcmBuffering(false); mTrack->stop(); } #ifdef WIN32 time_t now; time(&now); int time_int = (int)now; #else timeval now; gettimeofday(&now, NULL); int time_int = now.tv_sec; #endif Rand r; r.seed(time_int); int rand_file = r.nextInt(m_FileList.size()); path my_path = m_FileList[rand_file].path(); m_CurrentFile = my_path.string(); if(!write_frames) { mAudioSource = audio::load(m_CurrentFile); mTrack = audio::Output::addTrack(mAudioSource, false); mTrack->enablePcmBuffering(true); mTrack->play(); } //rot_inc = r.nextFloat(1.5f, 30.0f); }
/**Load images by list of files 'file_list' and store them in 'data_set' */ void LoadImages(const TFileList& file_list, TDataSet* data_set) { for (size_t img_idx = 0; img_idx < file_list.size(); ++img_idx) { // Create image BMP* image = new BMP(); // Read image from file image->ReadFromFile(file_list[img_idx].first.c_str()); // Add image and it's label to dataset data_set->push_back(make_pair(image, file_list[img_idx].second)); } }
void CApplication::initLocales() { boost::locale::generator gen; string path = getBasePath().normalize().string() + "/messages"; gen.add_messages_path(path); TExtensionList extensions = boost::assign::list_of (".mo"); TFileList translations = CFile::find(boost::filesystem::path(path), extensions, TExcludeList(), -1, false); vector<string> domains; for (TFileList::const_iterator iter = translations.begin(); iter != translations.end(); ++iter) { domains.push_back(boost::filesystem::basename(*iter)); } std::unique(domains.begin(), domains.end()); for (vector<string>::const_iterator iter = domains.begin(); iter != domains.end(); ++iter) { gen.add_messages_domain(*iter); } for (vector<string>::const_iterator iter = _languages.begin(); iter != _languages.end(); ++iter) { _locales[*iter] = gen(*iter + ".UTF-8"); } }
int __fastcall ns_Functions::GetFileList(TFileList &FileList, const String &Mask, bool Recursive, int Size) { String PathMask=ExtractFilePath(Mask), FileMask=ExtractFileName(Mask); TSearchRec F; if(!FindFirst(Mask, faAnyFile&~faDirectory, F)) { do { FileList.push_back((PathMask+F.Name).LowerCase()); Size += F.Size; } while(!FindNext(F)); FindClose(F); } if(!Recursive) return Size; if(!FindFirst(PathMask+"*", faAnyFile, F)) { do if(F.Attr&faDirectory && F.Name!="." && F.Name!="..") Size += GetFileList(FileList, PathMask+F.Name+"\\"+FileMask, Recursive, Size); while(!FindNext(F)); FindClose(F); } return Size; }
FileSystemUtils::Path RuntimeObjectSystem::FindFile( const FileSystemUtils::Path& input ) { FileSystemUtils::Path requestedDirectory = input; FileSystemUtils::Path filename; FileSystemUtils::Path foundFile = input; bool bIsFile = input.HasExtension(); if( bIsFile ) { requestedDirectory = requestedDirectory.ParentPath(); filename = input.Filename(); } requestedDirectory.ToOSCanonicalCase(); filename.ToOSCanonicalCase(); foundFile.ToOSCanonicalCase(); // Step 1: Try input directory if( requestedDirectory.Exists() ) { m_FoundSourceDirectoryMappings[ requestedDirectory ] = requestedDirectory; } else { // Step 2: Attempt to find a pre-existing mapping bool bFoundMapping = false; if( m_FoundSourceDirectoryMappings.size() ) { FileSystemUtils::Path testDir = requestedDirectory; FileSystemUtils::Path foundDir; unsigned int depth = 0; bool bFound = false; while( testDir.HasParentPath() ) { TFileMapIterator itrFind = m_FoundSourceDirectoryMappings.find( testDir ); if( itrFind != m_FoundSourceDirectoryMappings.end() ) { foundDir = itrFind->second; bFound = true; break; } testDir = testDir.ParentPath(); ++depth; } if( bFound ) { if( depth ) { // not an exact match FileSystemUtils::Path directory = requestedDirectory; directory.m_string.replace( 0, testDir.m_string.length(), foundDir.m_string ); if( directory.Exists() ) { foundFile = directory / filename; if( foundFile.Exists() ) { m_FoundSourceDirectoryMappings[ requestedDirectory ] = directory; if( m_pCompilerLogger ) { m_pCompilerLogger->LogInfo( "Found Directory Mapping: %s to %s\n", requestedDirectory.c_str(), directory.c_str() ); } bFoundMapping = true; } } } else { // exact match foundFile = foundDir / filename; bFoundMapping = true; } } if( !bFoundMapping ) { // Step 3: Attempt to find a mapping from a known path TFileList requestedSubPaths; FileSystemUtils::Path requestedSubPath = requestedDirectory; while( requestedSubPath.HasParentPath() ) { requestedSubPaths.push_back( requestedSubPath ); requestedSubPath = requestedSubPath.ParentPath(); } TFileMapIterator itr = m_FoundSourceDirectoryMappings.begin(); while( ( itr != m_FoundSourceDirectoryMappings.end() ) && !bFoundMapping ) { FileSystemUtils::Path existingPath = itr->second; while( ( existingPath.HasParentPath() ) && !bFoundMapping ) { // check all potentials for( size_t i=0; i<requestedSubPaths.size(); ++i ) { FileSystemUtils::Path toCheck = existingPath / requestedSubPaths[i].Filename(); if( toCheck.Exists() ) { // potential mapping FileSystemUtils::Path directory = requestedDirectory; directory.m_string.replace( 0, requestedSubPaths[i].m_string.length(), toCheck.m_string ); if( directory.Exists() ) { foundFile = directory / filename; if( foundFile.Exists() ) { m_FoundSourceDirectoryMappings[ requestedDirectory ] = directory; if( m_pCompilerLogger ) { m_pCompilerLogger->LogInfo( "Found Directory Mapping: %s to %s\n", requestedDirectory.c_str(), directory.c_str() ); } bFoundMapping = true; break; } } } } existingPath = existingPath.ParentPath(); } ++itr; } } } } if( !foundFile.Exists() ) { if( m_pCompilerLogger ) { m_pCompilerLogger->LogWarning( "Could not find Directory Mapping for: %s\n", input.c_str() ); } ++m_NumNotFoundSourceFiles; } return foundFile; }
//************************************************************************* void BeatDetectorApp::setup() { // Set up window setWindowSize(480, 480); // Set up OpenGL gl::enableAlphaBlending(); //glBlendFunc(GL_SRC_ALPHA, GL_ONE); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); //glEnable(GL_LINE_SMOOTH); //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); if(write_frames) { setFrameRate(30); } else { setFrameRate(60); } // Set line color gl::color(Color(1, 1, 1)); // Load and play audio //mAudioSource = audio::load(loadResource(RES_SAMPLE)); //mTrack = audio::Output::addTrack(mAudioSource, false); ///mTrack->enablePcmBuffering(true); //mTrack->play(); // Set init flag mFftInit = false; std::string dir = getHomeDirectory() + "music\\4vis"; if(exists(dir)) { if(is_directory(dir)) { copy(directory_iterator(dir), directory_iterator(), back_inserter(m_FileList)); } } for(TFileList::iterator it = m_FileList.begin(); it != m_FileList.end();) { //std::string str = it->path().native(); std::string str = it->path().generic_string(); //#ifdef WIN32 // if(str.rfind(".wav") != -1) //#else if(str.rfind(".mp3") != -1 || str.rfind(".m4a") != -1) //#endif { ++it; } else { it = m_FileList.erase(it); } } NextFile(); if(write_frames) { COpenALSampleManager::StaticInit(); p_sample = COpenALSampleManager::CreateSample(m_CurrentFile); } }