254 |
if(Path.compare("/") != 0) s += "/"; |
if(Path.compare("/") != 0) s += "/"; |
255 |
int res = sqlite3_step(pStmt); |
int res = sqlite3_step(pStmt); |
256 |
while(res == SQLITE_ROW) { |
while(res == SQLITE_ROW) { |
257 |
pDirectories->push_back(s + ToString(sqlite3_column_text(pStmt, 0))); |
pDirectories->push_back(s + idb->toAbstractName(ToString(sqlite3_column_text(pStmt, 0)))); |
258 |
res = sqlite3_step(pStmt); |
res = sqlite3_step(pStmt); |
259 |
} |
} |
260 |
|
|
339 |
if(Path.compare("/") != 0) s += "/"; |
if(Path.compare("/") != 0) s += "/"; |
340 |
int res = sqlite3_step(pStmt); |
int res = sqlite3_step(pStmt); |
341 |
while(res == SQLITE_ROW) { |
while(res == SQLITE_ROW) { |
342 |
pInstruments->push_back(s + ToString(sqlite3_column_text(pStmt, 0))); |
pInstruments->push_back(s + idb->toAbstractName(ToString(sqlite3_column_text(pStmt, 0)))); |
343 |
res = sqlite3_step(pStmt); |
res = sqlite3_step(pStmt); |
344 |
} |
} |
345 |
|
|
391 |
} |
} |
392 |
|
|
393 |
int dstDirId = db->GetDirectoryId(dir); |
int dstDirId = db->GetDirectoryId(dir); |
394 |
if(dstDirId == -1) throw Exception("Unkown DB directory: " + dir); |
if(dstDirId == -1) { |
395 |
|
throw Exception("Unkown DB directory: " + InstrumentsDb::toEscapedPath(dir)); |
396 |
|
} |
397 |
IntListPtr ids = db->GetInstrumentIDs(DirId); |
IntListPtr ids = db->GetInstrumentIDs(DirId); |
398 |
for (int i = 0; i < ids->size(); i++) { |
for (int i = 0; i < ids->size(); i++) { |
399 |
String name = db->GetInstrumentName(ids->at(i)); |
String name = db->GetInstrumentName(ids->at(i)); |
490 |
default: |
default: |
491 |
throw Exception("Unknown scan mode"); |
throw Exception("Unknown scan mode"); |
492 |
} |
} |
493 |
|
|
494 |
|
// Just to be sure that the frontends will be notified about the job completion |
495 |
|
if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) { |
496 |
|
Progress.SetTotalFileCount(Progress.GetScannedFileCount()); |
497 |
|
} |
498 |
|
if (Progress.GetStatus() != 100) Progress.SetStatus(100); |
499 |
} catch(Exception e) { |
} catch(Exception e) { |
500 |
Progress.SetErrorStatus(-1); |
Progress.SetErrorStatus(-1); |
501 |
throw e; |
throw e; |
521 |
continue; |
continue; |
522 |
} |
} |
523 |
|
|
524 |
count++; |
String s(pEnt->d_name); |
525 |
|
if(s.length() < 4) { |
526 |
|
pEnt = readdir(pDir); |
527 |
|
continue; |
528 |
|
} |
529 |
|
if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) count++; |
530 |
|
|
531 |
pEnt = readdir(pDir); |
pEnt = readdir(pDir); |
532 |
} |
} |
533 |
|
|
552 |
} |
} |
553 |
|
|
554 |
void AddInstrumentsFromFileJob::Run() { |
void AddInstrumentsFromFileJob::Run() { |
555 |
InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress); |
try { |
556 |
|
InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index, &Progress); |
557 |
|
|
558 |
|
// Just to be sure that the frontends will be notified about the job completion |
559 |
|
if (Progress.GetTotalFileCount() != Progress.GetScannedFileCount()) { |
560 |
|
Progress.SetTotalFileCount(Progress.GetScannedFileCount()); |
561 |
|
} |
562 |
|
if (Progress.GetStatus() != 100) Progress.SetStatus(100); |
563 |
|
} catch(Exception e) { |
564 |
|
Progress.SetErrorStatus(-1); |
565 |
|
throw e; |
566 |
|
} |
567 |
} |
} |
568 |
|
|
569 |
|
|
616 |
} |
} |
617 |
|
|
618 |
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
|
if (!db->DirectoryExist(dir)) db->AddDirectory(dir); |
|
619 |
|
|
620 |
db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress); |
if (HasInstrumentFiles(String(fpath))) { |
621 |
|
if (!db->DirectoryExist(dir)) db->AddDirectory(dir); |
622 |
|
db->AddInstrumentsNonrecursive(dir, String(fpath), pProgress); |
623 |
|
} |
624 |
|
|
625 |
return 0; |
return 0; |
626 |
}; |
}; |
627 |
|
|
628 |
|
bool DirectoryScanner::HasInstrumentFiles(String Dir) { |
629 |
|
return InstrumentFileCounter::Count(Dir) > 0; |
630 |
|
} |
631 |
|
|
632 |
int InstrumentFileCounter::FileCount; |
int InstrumentFileCounter::FileCount; |
633 |
|
|
634 |
int InstrumentFileCounter::Count(String FsDir) { |
int InstrumentFileCounter::Count(String FsDir) { |
657 |
String s = fpath; |
String s = fpath; |
658 |
if(s.length() < 4) return 0; |
if(s.length() < 4) return 0; |
659 |
if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++; |
if(!strcasecmp(".gig", s.substr(s.length() - 4).c_str())) FileCount++; |
660 |
|
|
661 |
return 0; |
return 0; |
662 |
}; |
}; |
663 |
|
|