void GMSyncTask::import_and_update(){ FXStat data; FXString name; database->beginTask(); taskmanager->setStatus("Syncing Files.."); for (FXint i=0;i<files.no() && processing;i++) { if (FXStat::statLink(files[i],data)) { if (data.isDirectory()) { if(!(name[0]=='.' && (name[1]==0 || (name[1]=='.' && name[2]==0)))) { if(files[i].tail()==PATHSEP) traverse(files[i].rafter(PATHSEP),nullptr,data.index()); else traverse(files[i],nullptr,data.index()); } } } } if (changed) { database->sync_album_year(); database->sync_tracks_removed(); } database->commitTask(); }
void GMSyncTask::traverse(const FXString & path,Seen * seen,FXlong index) { FXDir directory; FXStat data; FXString name; // Location Seen here={seen,index}; // First scan subfolders if (directory.open(path)) { while(directory.next(name) && processing) { if (FXStat::statLink(path+PATHSEPSTRING+name,data)) { if (data.isDirectory()) { if(!(name[0]=='.' && (name[1]==0 || (name[1]=='.' && name[2]==0)))){ for(Seen *s=seen; s; s=s->next){ if(data.index()==s->node) goto next_dir; } if (options.exclude_folder.empty() || !FXPath::match(name,options.exclude_folder,matchflags)) traverse(path+PATHSEPSTRING+name,&here,data.index()); } } } next_dir:; } directory.close(); } // Scan files in current folder if(directory.open(path) && processing) { FXint path_index = dbtracks.hasPath(path); while(directory.next(name) && processing) { if (FXStat::statFile(path+PATHSEPSTRING+name,data)) { if (!data.isDirectory() && data.isReadable()) { if (options.exclude_file.empty() || !FXPath::match(name,options.exclude_file,matchflags)) { if (FXPath::match(name,FILE_PATTERNS,matchflags)) { parse_update(path,name,options_sync.update_always ? forever : data.modified(),path_index); } } } } } if (processing) update_tracks(path_index); } }
void GMImportTask::import() { FXStat data; FXString name; FXint dircount=0; database->beginTask(); if (dbtracks.playlist) dbtracks.playlist_queue = database->getNextQueue(dbtracks.playlist); // Run through all directories for (FXint i=0;i<files.no() && processing;i++) { if (FXStat::statLink(files[i],data)) { if (data.isDirectory()) { if(!(name[0]=='.' && (name[1]==0 || (name[1]=='.' && name[2]==0)))) { if(files[i].tail()==PATHSEP) scan(files[i].rafter(PATHSEP),nullptr,data.index()); else scan(files[i],nullptr,data.index()); } dircount++; } } } // Scan remaining files if (dircount<files.no()) { for (FXint i=0;i<files.no() && processing;i++) { if (FXStat::statFile(files[i],data)) { if (!data.isDirectory() && data.isReadable()) { const FXString path = FXPath::directory(files[i]); const FXString name = FXPath::name(files[i]); if (FXPath::match(name,FILE_PATTERNS,matchflags)){ FXint path_index = dbtracks.hasPath(path); parse(path,name,path_index); } } } } import_tracks(); } database->sync_album_year(); database->commitTask(); }