/[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 1908 by persson, Mon Jun 1 18:50:06 2009 UTC revision 1944 by persson, Tue Jul 14 18:54:08 2009 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2007-2009 Grigor Iliev                                 *   *   Copyright (C) 2007-2009 Grigor Iliev, Benno Senoner                   *
4   *                                                                         *   *                                                                         *
5   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
6   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 27  Line 27 
27  #include <iostream>  #include <iostream>
28  #include <sstream>  #include <sstream>
29  #include <vector>  #include <vector>
30    #include <algorithm>
31  #include <errno.h>  #include <errno.h>
32  #ifndef WIN32  #ifndef WIN32
33  #include <fnmatch.h>  #include <fnmatch.h>
34    #else
35    #include <direct.h>
36  #endif  #endif
   
37  #include "../common/Exception.h"  #include "../common/Exception.h"
38    
39  namespace LinuxSampler {  namespace LinuxSampler {
# Line 89  namespace LinuxSampler { Line 91  namespace LinuxSampler {
91    
92      InstrumentsDb::InstrumentsDb() {      InstrumentsDb::InstrumentsDb() {
93          db = NULL;          db = NULL;
         DbInstrumentsMutex = Mutex();  
94          InTransaction = false;          InTransaction = false;
95      }      }
96    
# Line 122  namespace LinuxSampler { Line 123  namespace LinuxSampler {
123      sqlite3* InstrumentsDb::GetDb() {      sqlite3* InstrumentsDb::GetDb() {
124          if ( db != NULL) return db;          if ( db != NULL) return db;
125    
126          if (DbFile.empty()) DbFile = CONFIG_DEFAULT_INSTRUMENTS_DB_LOCATION;          if (DbFile.empty()) {
127                        #ifndef WIN32
128                        DbFile = CONFIG_DEFAULT_INSTRUMENTS_DB_LOCATION;
129                            #else
130                            char *userprofile = getenv("USERPROFILE");
131                            if(userprofile) {
132                                String DbPath = userprofile;
133                                    DbPath += "\\.linuxsampler";
134                                DbFile = DbPath + "\\instruments.db";
135                                    File InstrumentsDbFile(DbFile);
136                                    // if no DB exists create the subdir and then the DB
137                                    if( !InstrumentsDbFile.Exist() ) {
138                                        _mkdir( DbPath.c_str() );
139                                            // formats the DB, which creates a new instruments.db file
140                                            Format();
141                                    }
142                        }
143                            else {
144                                // in case USERPROFILE is not set (which should not occur)
145                                DbFile = "instruments.db";
146                            }
147                            #endif
148                }
149                  #if defined(__APPLE__)  /* 20071224 Toshi Nagata  */                  #if defined(__APPLE__)  /* 20071224 Toshi Nagata  */
150                  if (DbFile.find("~") == 0)                  if (DbFile.find("~") == 0)
151                          DbFile.replace(0, 1, getenv("HOME"));                          DbFile.replace(0, 1, getenv("HOME"));
# Line 1202  namespace LinuxSampler { Line 1225  namespace LinuxSampler {
1225                  throw Exception("DB error: " + ToString(sqlite3_errmsg(db)));                  throw Exception("DB error: " + ToString(sqlite3_errmsg(db)));
1226              }              }
1227    
1228              String s = toEscapedFsPath(FilePath);              String s = FilePath;
1229                s = toEscapedFsPath(s);
1230              BindTextParam(pStmt, 2, s);              BindTextParam(pStmt, 2, s);
1231              String ver = "";              String ver = "";
1232              if (gig->pVersion != NULL) ver = ToString(gig->pVersion->major);              if (gig->pVersion != NULL) ver = ToString(gig->pVersion->major);
# Line 1834  namespace LinuxSampler { Line 1858  namespace LinuxSampler {
1858      }      }
1859            
1860      String InstrumentsDb::toEscapedFsPath(String FsPath) {      String InstrumentsDb::toEscapedFsPath(String FsPath) {
1861    #ifdef WIN32
1862            replace(FsPath.begin(), FsPath.end(), '\\', '/');
1863    #endif
1864          return toEscapedText(FsPath);          return toEscapedText(FsPath);
1865      }      }
1866            
1867      String InstrumentsDb::toNonEscapedFsPath(String FsPath) {      String InstrumentsDb::toNonEscapedFsPath(String FsPath) {
1868          return toNonEscapedText(FsPath);          FsPath = toNonEscapedText(FsPath);
1869    #ifdef WIN32
1870            replace(FsPath.begin(), FsPath.end(), '/', '\\');
1871    #endif
1872            return FsPath;
1873      }      }
1874            
1875      String InstrumentsDb::toAbstractName(String DbName) {      String InstrumentsDb::toAbstractName(String DbName) {

Legend:
Removed from v.1908  
changed lines
  Added in v.1944

  ViewVC Help
Powered by ViewVC