/[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 1345 by iliev, Thu Sep 13 21:46:25 2007 UTC
# Line 254  namespace LinuxSampler { Line 254  namespace LinuxSampler {
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                    
# Line 339  namespace LinuxSampler { Line 339  namespace LinuxSampler {
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                    
# Line 391  namespace LinuxSampler { Line 391  namespace LinuxSampler {
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));
# Line 488  namespace LinuxSampler { Line 490  namespace LinuxSampler {
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;
# Line 513  namespace LinuxSampler { Line 521  namespace LinuxSampler {
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                    
# Line 538  namespace LinuxSampler { Line 552  namespace LinuxSampler {
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    
# Line 591  namespace LinuxSampler { Line 616  namespace LinuxSampler {
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) {
# Line 626  namespace LinuxSampler { Line 657  namespace LinuxSampler {
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    

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

  ViewVC Help
Powered by ViewVC