/[svn]/linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/db/InstrumentsDbUtilities.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1200 by iliev, Thu May 24 14:04:18 2007 UTC revision 1208 by iliev, Sat May 26 22:20:46 2007 UTC
# Line 488  namespace LinuxSampler { Line 488  namespace LinuxSampler {
488                  default:                  default:
489                      throw Exception("Unknown scan mode");                      throw Exception("Unknown scan mode");
490              }              }
491    
492                // Just to be sure that the frontends will be notified about the job completion
493                if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) {
494                    Progress.SetTotalFileCount(Progress.GetScannedFileCount());
495                }
496                if (Progress.GetStatus() != 100) Progress.SetStatus(100);
497          } catch(Exception e) {          } catch(Exception e) {
498              Progress.SetErrorStatus(-1);              Progress.SetErrorStatus(-1);
499              throw e;              throw e;
# Line 513  namespace LinuxSampler { Line 519  namespace LinuxSampler {
519                  continue;                  continue;
520              }              }
521    
522              count++;              String s(pEnt->d_name);
523                if(s.length() < 4) {
524                    pEnt = readdir(pDir);
525                    continue;
526                }
527                if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) count++;
528    
529              pEnt = readdir(pDir);              pEnt = readdir(pDir);
530          }          }
531                    
# Line 538  namespace LinuxSampler { Line 550  namespace LinuxSampler {
550      }      }
551    
552      void AddInstrumentsFromFileJob::Run() {      void AddInstrumentsFromFileJob::Run() {
553          InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress);          try {
554                InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress);
555    
556                // Just to be sure that the frontends will be notified about the job completion
557                if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) {
558                    Progress.SetTotalFileCount(Progress.GetScannedFileCount());
559                }
560                if (Progress.GetStatus() != 100) Progress.SetStatus(100);
561            } catch(Exception e) {
562                Progress.SetErrorStatus(-1);
563                throw e;
564            }
565      }      }
566    
567    
# Line 591  namespace LinuxSampler { Line 614  namespace LinuxSampler {
614          }          }
615                    
616          InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb();          InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb();
         if (!db->DirectoryExist(dir)) db->AddDirectory(dir);  
617    
618          db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress);          if (HasInstrumentFiles(String(fpath))) {
619                if (!db->DirectoryExist(dir)) db->AddDirectory(dir);
620                db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress);
621            }
622    
623          return 0;          return 0;
624      };      };
625    
626        bool DirectoryScanner::HasInstrumentFiles(String Dir) {
627            return InstrumentFileCounter::Count(Dir) > 0;
628        }
629    
630      int InstrumentFileCounter::FileCount;      int InstrumentFileCounter::FileCount;
631    
632      int InstrumentFileCounter::Count(String FsDir) {      int InstrumentFileCounter::Count(String FsDir) {
# Line 626  namespace LinuxSampler { Line 655  namespace LinuxSampler {
655          String s = fpath;          String s = fpath;
656          if(s.length() < 4) return 0;          if(s.length() < 4) return 0;
657          if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++;          if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++;
658    
659          return 0;          return 0;
660      };      };
661    

Legend:
Removed from v.1200  
changed lines
  Added in v.1208

  ViewVC Help
Powered by ViewVC