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; |
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 |
|
|
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 |
|
|
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) { |
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 |
|
|