commit 190a58cc12869bc465a10c7c9d4fd62624e5b3c0
parent f7f9f7e314ecf546d32730a06ad6b5b51634b3ae
Author: paulnasca <paulnasca>
Date: Wed, 3 Mar 2004 18:31:18 +0000
*** empty log message ***
Diffstat:
3 files changed, 71 insertions(+), 52 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -552,7 +552,8 @@
01 Mar 2004 - Se pot schimba bancile de instrumente
- Introduse si celelalte functii la Bank (cu exceptia salvarii/incarcarii locului bancii folosite)
- Se poate importa banci din bnk_zyn
-
+03 Mar 2004 - Terminat (teoretic) partea de XML
+
diff --git a/src/Misc/Bank.C b/src/Misc/Bank.C
@@ -27,6 +27,12 @@
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+
Bank::Bank(){
memset(defaultinsname,0,PART_MAX_NAME_LEN);
snprintf(defaultinsname,PART_MAX_NAME_LEN,"%s"," ");
@@ -36,16 +42,77 @@ Bank::Bank(){
ins[i].filename=NULL;
};
dirname=NULL;
-
clearbank();
- loadbank("bank_xml");
+
+ char bankcfg[1000];//hope the filename is shorter than that :)
+#if defined(OS_WINDOWS)
+ strcpy(bankcfg,"zynaddsubfx_usedbank");
+#endif
+#if defined(OS_LINUX)
+ strcpy(bankcfg,getenv("HOME"));
+ strcat(bankcfg,"/.zynaddsubfx_usedbank");
+#endif
+
+
+ struct stat statbuf;
+ int result=stat(bankcfg,&statbuf);
+ if (result==0){
+ char *fn=new char [statbuf.st_size+2];
+ for (int i=0;i<statbuf.st_size;i++) fn[i]=0;
+ int file=open(bankcfg,O_RDONLY,00444+00222);
+ if (file!=-1){
+ read(file,fn,statbuf.st_size);
+
+ loadbank(fn);
+ };
+ close(file);
+ delete(fn);
+ } else {
+
+ result=1;
+#if defined(OS_LINUX)
+ result=stat("/usr/local/share/zynaddsubfx/default_bank",&statbuf);
+ if (result==0) loadbank("/usr/local/share/zynaddsubfx/default_bank");
+ else {
+ result=stat("/usr/share/zynaddsubfx/default_bank",&statbuf);
+ if (result==0) loadbank("/usr/share/zynaddsubfx/default_bank");
+ };
+#endif
+ if (result!=0) loadbank("default_bank");
+ };
+
+
+
+// loadbank("bank_xml");
+
+
+
bankfiletitle=dirname;
};
Bank::~Bank(){
+ //**************//
+ char bankcfg[1000];//hope the filename is shorter than that :)
+#if defined(OS_WINDOWS)
+ strcpy(bankcfg,"zynaddsubfx_usedbank");
+#endif
+#if defined(OS_LINUX)
+ strcpy(bankcfg,getenv("HOME"));
+ strcat(bankcfg,"/.zynaddsubfx_usedbank");
+#endif
+
+ int file=open(bankcfg,O_CREAT|O_WRONLY|O_TRUNC,00444+00222);
+ if (file!=-1){
+ write(file,dirname,strlen(dirname)+1);
+ close(file);
+ };
+ //**************//
+
+
+
clearbank();
};
diff --git a/src/Misc/OldBank.C b/src/Misc/OldBank.C
@@ -43,58 +43,9 @@ OldBank::OldBank(){
struct stat statbuf;
- char bankcfg[1000];//hope the filename is shorter than that :)
-#if defined(OS_WINDOWS)
- strcpy(bankcfg,"zynaddsubfx_usedbank");
-#endif
-#if defined(OS_LINUX)
- strcpy(bankcfg,getenv("HOME"));
- strcat(bankcfg,"/.zynaddsubfx_usedbank");
-#endif
-
- int result=stat(bankcfg,&statbuf);
- if (result==0){
- char *fn=new char [statbuf.st_size+2];
- for (int i=0;i<statbuf.st_size;i++) fn[i]=0;
- int file=open(bankcfg,O_RDONLY,00444+00222);
- if (file!=-1){
- read(file,fn,statbuf.st_size);
- loadfilebank(fn);
- };
- close(file);
- delete(fn);
- } else {
-
- result=1;
-#if defined(OS_LINUX)
- result=stat("/usr/local/share/zynaddsubfx/default.bnk_zyn",&statbuf);
- if (result==0) loadfilebank("/usr/local/share/zynaddsubfx/default.bnk_zyn");
- else {
- result=stat("/usr/share/zynaddsubfx/default.bnk_zyn",&statbuf);
- if (result==0) loadfilebank("/usr/share/zynaddsubfx/default.bnk_zyn");
- };
-#endif
- if (result!=0) loadfilebank("default.bnk_zyn");
- };
};
OldBank::~OldBank(){
- if (bankfilename==NULL) return;
-
- char bankcfg[1000];//hope the filename is shorter than that :)
-#if defined(OS_WINDOWS)
- strcpy(bankcfg,"zynaddsubfx_usedbank");
-#endif
-#if defined(OS_LINUX)
- strcpy(bankcfg,getenv("HOME"));
- strcat(bankcfg,"/.zynaddsubfx_usedbank");
-#endif
-
- int file=open(bankcfg,O_CREAT|O_WRONLY|O_TRUNC,00444+00222);
- if (file!=-1){
- write(file,bankfilename,strlen(bankfilename)+1);
- close(file);
- };
savefile();
};