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

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

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

revision 1353 by iliev, Mon Sep 17 23:15:25 2007 UTC revision 1642 by nagata, Sun Jan 13 16:36:14 2008 UTC
# Line 20  Line 20 
20    
21  #include "InstrumentsDb.h"  #include "InstrumentsDb.h"
22    
23  #if HAVE_SQLITE3  #include "../common/global_private.h"
24    
25  #include <iostream>  #include <iostream>
26  #include <sstream>  #include <sstream>
# Line 127  namespace LinuxSampler { Line 127  namespace LinuxSampler {
127      sqlite3* InstrumentsDb::GetDb() {      sqlite3* InstrumentsDb::GetDb() {
128          if ( db != NULL) return db;          if ( db != NULL) return db;
129    
130          if (DbFile.empty()) DbFile = "/var/lib/linuxsampler/instruments.db";          if (DbFile.empty()) DbFile = CONFIG_DEFAULT_INSTRUMENTS_DB_LOCATION;
131                    #if defined(__APPLE__)  /* 20071224 Toshi Nagata  */
132                    if (DbFile.find("~") == 0)
133                            DbFile.replace(0, 1, getenv("HOME"));
134                    #endif
135          int rc = sqlite3_open(DbFile.c_str(), &db);          int rc = sqlite3_open(DbFile.c_str(), &db);
136          if (rc) {          if (rc) {
137              sqlite3_close(db);              sqlite3_close(db);
# Line 1168  namespace LinuxSampler { Line 1172  namespace LinuxSampler {
1172          try {          try {
1173              riff = new RIFF::File(File);              riff = new RIFF::File(File);
1174              gig::File* gig = new gig::File(riff);              gig::File* gig = new gig::File(riff);
1175                gig->SetAutoLoad(false); // avoid time consuming samples scanning
1176    
1177              std::stringstream sql;              std::stringstream sql;
1178              sql << "INSERT INTO instruments (dir_id,instr_name,instr_file,";              sql << "INSERT INTO instruments (dir_id,instr_name,instr_file,";
# Line 1630  namespace LinuxSampler { Line 1635  namespace LinuxSampler {
1635              db = NULL;              db = NULL;
1636          }          }
1637    
1638          if (DbFile.empty()) DbFile = "/var/lib/linuxsampler/instruments.db";          if (DbFile.empty()) DbFile = CONFIG_DEFAULT_INSTRUMENTS_DB_LOCATION;
1639          String bkp = DbFile + ".bkp";          String bkp = DbFile + ".bkp";
1640          remove(bkp.c_str());          remove(bkp.c_str());
1641          if (rename(DbFile.c_str(), bkp.c_str()) && errno != ENOENT) {          if (rename(DbFile.c_str(), bkp.c_str()) && errno != ENOENT) {
# Line 1755  namespace LinuxSampler { Line 1760  namespace LinuxSampler {
1760      }      }
1761    
1762  } // namespace LinuxSampler  } // namespace LinuxSampler
   
 #endif // HAVE_SQLITE3  

Legend:
Removed from v.1353  
changed lines
  Added in v.1642

  ViewVC Help
Powered by ViewVC