zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit f67a86c462093ea830c9b057472fc1fa4efa7dc8
parent 482fa521a9773b171ce7ea1280062c409923e8d6
Author: paulnasca <paulnasca>
Date:   Sat, 12 Jun 2004 18:32:49 +0000

*** empty log message ***

Diffstat:
Msrc/Misc/Bank.C | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Msrc/Misc/Bank.h | 7+++++++
2 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/src/Misc/Bank.C b/src/Misc/Bank.C @@ -156,7 +156,7 @@ void Bank::setname(unsigned int ninstrument,const char *newname){ for (int i=0;i<4;i++) if (tmpfilename[i]==' ') tmpfilename[i]='0'; //make the filenames legal - for (int i=0;i<strlen(tmpfilename);i++) { + for (int i=0;i<(int) strlen(tmpfilename);i++) { char c=tmpfilename[i]; if ((c>='0')&&(c<='9')) continue; if ((c>='A')&&(c<='Z')) continue; @@ -209,7 +209,7 @@ void Bank::savetoslot(unsigned int ninstrument,Part *part){ for (int i=0;i<4;i++) if (tmpfilename[i]==' ') tmpfilename[i]='0'; //make the filenames legal - for (int i=0;i<strlen(tmpfilename);i++) { + for (int i=0;i<(int)strlen(tmpfilename);i++) { char c=tmpfilename[i]; if ((c>='0')&&(c<='9')) continue; if ((c>='A')&&(c<='Z')) continue; @@ -268,7 +268,6 @@ int Bank::loadbank(const char *bankdirname){ // printf("%s/\n",bankdirname); struct dirent *fn; - while ((fn=readdir(dir))){ if (fn->d_type!=DT_REG) continue;//this is not a regular file @@ -364,7 +363,63 @@ void Bank::rescanforbanks(){ // private stuff void Bank::scanrootdir(char *rootdir){ - printf("Scanning root dir:%s\n",rootdir); +// printf("Scanning root dir:%s\n",rootdir); + DIR *dir=opendir(rootdir); + if (dir==NULL) return; + + const int maxdirsize=1000; + struct { + char dir[maxdirsize]; + char name[maxdirsize]; + }bank; + + char *separator="/"; + if (strlen(rootdir)) { + char tmp=rootdir[strlen(rootdir)-1]; + if ((tmp=='/') || (tmp=='\\')) separator=""; + }; + + struct dirent *fn; + while ((fn=readdir(dir))){ + if (fn->d_type!=DT_DIR) continue;//this is not a directory + const char *dirname=fn->d_name; + if (dirname[0]=='.') continue; + + snprintf(bank.dir,maxdirsize,"%s%s%s/",rootdir,separator,dirname); + snprintf(bank.name,maxdirsize,"%s",dirname); + //find out if the directory contains at least 1 instrument + bool isbank=false; + + DIR *d=opendir(bank.dir); + if (d==NULL) continue; + + struct dirent *fname; + + while((fname=readdir(d))){ + if (fname->d_type!=DT_REG) continue;//this is not a regular file + if (strstr(fname->d_name,INSTRUMENT_EXTENSION)!=NULL) { + isbank=true; + break;//aici as putea pune in loc de break un update la un counter care imi arata nr. de instrumente din bank + }; + }; + + closedir(d); + + if (isbank) printf("%s = %s\n",bank.dir,bank.name); + + }; + + closedir(dir); +/* + + // printf("%s/\n",bankdirname); + struct dirent *fn; + + while ((fn=readdir(dir))){ + if (fn->d_type!=DT_REG) continue;//this is not a regular file + const char *filename= fn->d_name; +*/ + }; void Bank::clearbank(){ diff --git a/src/Misc/Bank.h b/src/Misc/Bank.h @@ -53,6 +53,13 @@ class Bank{ void rescanforbanks(); + struct bankstruct{ + char dir[maxdirsize]; + char name[maxdirsize]; + }; + +/// banks[ + private: //it adds a filename to the bank