Ejemplo n.º 1
0
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();
  }
Ejemplo n.º 2
0
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);
    }
  }
Ejemplo n.º 3
0
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();
  }