/[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 1350 by iliev, Sun Sep 16 23:06:10 2007 UTC revision 1353 by iliev, Mon Sep 17 23:15:25 2007 UTC
# Line 1623  namespace LinuxSampler { Line 1623  namespace LinuxSampler {
1623          return Dir.substr(0, i);          return Dir.substr(0, i);
1624      }      }
1625    
1626        void InstrumentsDb::Format() {
1627            DbInstrumentsMutex.Lock();
1628            if (db != NULL) {
1629                sqlite3_close(db);
1630                db = NULL;
1631            }
1632    
1633            if (DbFile.empty()) DbFile = "/var/lib/linuxsampler/instruments.db";
1634            String bkp = DbFile + ".bkp";
1635            remove(bkp.c_str());
1636            if (rename(DbFile.c_str(), bkp.c_str()) && errno != ENOENT) {
1637                DbInstrumentsMutex.Unlock();
1638                throw Exception(String("Failed to backup database: ") + strerror(errno));
1639            }
1640            
1641            String f = DbFile;
1642            DbFile = "";
1643            try { CreateInstrumentsDb(f); }
1644            catch(Exception e) {
1645                DbInstrumentsMutex.Unlock();
1646                throw e;
1647            }
1648            DbInstrumentsMutex.Unlock();
1649            
1650            FireDirectoryCountChanged("/");
1651            FireInstrumentCountChanged("/");
1652        }
1653    
1654      void InstrumentsDb::CheckFileName(String File) {      void InstrumentsDb::CheckFileName(String File) {
1655          if (File.empty()) throw Exception("Invalid file name: " + File);          if (File.empty()) throw Exception("Invalid file name: " + File);
1656      }      }

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

  ViewVC Help
Powered by ViewVC