static void gmsplit(const FXString & in,FXStringList & output) { FXint s=0; FXint e=0; FXint n=0; const FXchar sep=','; while(s<in.length()) { // trim leading white space while(in[s]==' ') s++; e=s; // find end while(in[e]!=sep && in[e]!='\0') e++; n=e+1; e=e-1; // trim end while(e>=s && in[e]==' ') e--; if (e>=s) { output.no(output.no()+1); output[output.no()-1].assign(&in[s],(e-s)+1); } s=n; } }
void InputThread::ctrl_open_inputs(const FXStringList & urls){ for (FXint i=0;i<urls.no();i++){ GM_DEBUG_PRINT("[input] ctrl_open_inputs[%d] %s\n",i,urls[i].text()); if (urls[i].empty()) continue; /// Open Input input=open_input(urls[i]); if (input==NULL) { if (aborted()) break; continue; } /// Open Reader reader = open_reader(); if (reader==NULL) continue; if (!reader->init(input)) continue; streamid++; set_state(StateProcessing,true); return; } ctrl_close_input(); set_state(StateIdle,true); }
void GMDBTracks::insertTags(FXint track,const FXStringList & tags){ FXIntList ids(tags.no()); for (int i=0;i<tags.no();i++) { ids[i]=0; query_tag.execute(tags[i],ids[i]); if (ids[i]==0) ids[i] = insert_tag.insert(tags[i]); } for (FXint i=0;i<ids.no();i++) { insert_track_tag.set(0,track); insert_track_tag.set(1,ids[i]); insert_track_tag.execute(); } }
void GMDBTracks::updateTags(FXint track,const FXStringList & tags){ /// Remove current tags delete_track_tags.update(track); /// Insert new tags if (tags.no()) insertTags(track,tags); }
ReadStatus ASXReader::process(Packet*packet) { if (TextReader::process(packet)==ReadDone) { gm_parse_asx(textbuffer,uri); if (uri.no()) return ReadRedirect; else return ReadDone; } return ReadError; }
void GMSyncTask::update() { GMTrackFilenameList tracklist; FXStringList pathlist; FXStat data; database->beginTask(); taskmanager->setStatus("Updating Files.."); for (FXint i=0;i<files.no() && processing;i++) { database->getPathList(files[i],pathlist); for (FXint p=0;p<pathlist.no() && processing;p++) { const FXString & path = pathlist[p]; if (!options.exclude_folder.empty() && filter_path(options.exclude_folder,path)) continue; const FXint path_index = dbtracks.hasPath(path); database->getFileList(path,tracklist); for (FXint t=0;t<tracklist.no() && processing;t++) { const FXString & name = tracklist[t].filename; if (options.exclude_file.empty() || !FXPath::match(name,options.exclude_file,matchflags)) { if (FXStat::statFile(path+PATHSEPSTRING+name,data)) { if (data.isReadable()) parse_update(path,name,options_sync.update_always ? forever : data.modified(),path_index); else parse_update(path,name,0,path_index); } else if (options_sync.remove_missing) { dbtracks.remove(tracklist[t].id); changed=true; } } } if (processing) update_tracks(path_index); } } if (changed) { database->sync_album_year(); database->sync_tracks_removed(); } database->commitTask(); }
FXint GMRenameTask::run() { try { for (FXint i=0;i<from.no() && processing;i++) { if (to[i].empty()) continue; if (!FXDir::createDirectories(FXPath::directory(to[i]))) continue; if (FXStat::exists(to[i])) continue; if (FXFile::moveFiles(from[i],to[i])){ database->setTrackFilename(tracks[i],to[i]); } } } catch(GMDatabaseException&) { GM_DEBUG_PRINT("Database Exception\n"); } return 0; }
void GMSyncTask::remove_missing() { FXStringList pathlist; GMTrackFilenameList tracklist; database->beginTask(); taskmanager->setStatus("Clearing Files.."); for (FXint i=0;i<files.no() && processing;i++) { database->getPathList(files[i],pathlist); for (FXint p=0;p<pathlist.no() && processing;p++) { if (!options.exclude_folder.empty() && filter_path(options.exclude_folder,pathlist[p])) continue; database->getFileList(pathlist[p],tracklist); for (FXint t=0;t<tracklist.no() && processing;t++) { const FXString & name = tracklist[t].filename; if (database->interrupt) database->waitTask(); if (options.exclude_file.empty() || !FXPath::match(name,options.exclude_file,matchflags)) { if (options_sync.remove_all || !FXStat::exists(pathlist[p]+PATHSEPSTRING+name)){ dbtracks.remove(tracklist[t].id); changed=true; } } } } } if (changed) database->sync_tracks_removed(); database->commitTask(); }