/[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 3100 by schoenebeck, Mon Jan 16 22:02:36 2017 UTC revision 3101 by schoenebeck, Sun Feb 5 18:03:58 2017 UTC
# Line 312  namespace LinuxSampler { Line 312  namespace LinuxSampler {
312          }          }
313                    
314          int id = 0, i = 1;          int id = 0, i = 1;
315          int j = Dir.find('/', i);          int j = (int) Dir.find('/', i);
316    
317          while(j != std::string::npos) {          while(j != std::string::npos) {
318              id = GetDirectoryId(id, Dir.substr(i, j - i));              id = GetDirectoryId(id, Dir.substr(i, j - i));
319              i = j + 1;              i = j + 1;
320              if (i >= Dir.length()) return id;              if (i >= Dir.length()) return id;
321              j = Dir.find('/', i);              j = (int) Dir.find('/', i);
322          }          }
323                    
324          return GetDirectoryId(id, Dir.substr(i));          return GetDirectoryId(id, Dir.substr(i));
# Line 1403  namespace LinuxSampler { Line 1403  namespace LinuxSampler {
1403                  File f(toNonEscapedFsPath(files->at(i)));                  File f(toNonEscapedFsPath(files->at(i)));
1404                  if (!f.Exist()) result->push_back(files->at(i));                  if (!f.Exist()) result->push_back(files->at(i));
1405              }              }
1406                EndTransaction();
1407              return result;              return result;
1408          } catch (Exception e) {          } catch (Exception e) {
1409              EndTransaction();              EndTransaction();
1410              throw e;              throw e;
1411          }          }
         EndTransaction();  
1412      }      }
1413            
1414      void InstrumentsDb::SetInstrumentFilePath(String OldPath, String NewPath) {      void InstrumentsDb::SetInstrumentFilePath(String OldPath, String NewPath) {
# Line 1703  namespace LinuxSampler { Line 1703  namespace LinuxSampler {
1703          if (File.at(0) != '/') String("");          if (File.at(0) != '/') String("");
1704          if (File.length() == 1) return File;          if (File.length() == 1) return File;
1705          if (File.at(File.length() - 1) == '/') return File.substr(0, File.length() - 1);          if (File.at(File.length() - 1) == '/') return File.substr(0, File.length() - 1);
1706          int i = File.rfind('/', File.length() - 1);          int i = (int) File.rfind('/', File.length() - 1);
1707          if(i == std::string::npos) return String("");          if(i == std::string::npos) return String("");
1708          if(i == 0) return String("/");          if(i == 0) return String("/");
1709          return File.substr(0, i);          return File.substr(0, i);
# Line 1713  namespace LinuxSampler { Line 1713  namespace LinuxSampler {
1713          if (Path.length() < 2) return String("");          if (Path.length() < 2) return String("");
1714          if (Path.at(0) != '/') String("");          if (Path.at(0) != '/') String("");
1715          if (Path.at(Path.length() - 1) == '/') return String("");          if (Path.at(Path.length() - 1) == '/') return String("");
1716          int i = Path.rfind('/', Path.length() - 1);          int i = (int) Path.rfind('/', Path.length() - 1);
1717          return Path.substr(i + 1);          return Path.substr(i + 1);
1718      }      }
1719    
1720      void InstrumentsDb::CheckPathName(String Path) {      void InstrumentsDb::CheckPathName(String Path) {
1721          if (Path.empty()) return;          if (Path.empty()) return;
1722    
1723          int i = 0, j = Path.find('/', i);          int i = 0, j = (int)Path.find('/', i);
1724    
1725          while(j != std::string::npos) {          while(j != std::string::npos) {
1726              if (j + 1 >= Path.length()) return;              if (j + 1 >= Path.length()) return;
1727              if (Path.at(j + 1) == '/') throw Exception("Invalid path name: " + Path);              if (Path.at(j + 1) == '/') throw Exception("Invalid path name: " + Path);
1728                            
1729              i = j + 1;              i = j + 1;
1730              j = Path.find('/', i);              j = (int) Path.find('/', i);
1731          }          }
1732      }      }
1733            
1734      String InstrumentsDb::GetParentDirectory(String Dir) {      String InstrumentsDb::GetParentDirectory(String Dir) {
1735          if (Dir.length() < 2) return String("");          if (Dir.length() < 2) return String("");
1736          if (Dir.at(0) != '/') String("");          if (Dir.at(0) != '/') String("");
1737          int i = Dir.rfind('/', Dir.length() - 2);          int i = (int) Dir.rfind('/', Dir.length() - 2);
1738          if (i == 0) return "/";          if (i == 0) return "/";
1739          return Dir.substr(0, i);          return Dir.substr(0, i);
1740      }      }

Legend:
Removed from v.3100  
changed lines
  Added in v.3101

  ViewVC Help
Powered by ViewVC