]> granicus.if.org Git - php/commitdiff
See the update to dba_db3.c
authorGavin Sherry <swm@php.net>
Sat, 12 Jan 2002 07:23:35 +0000 (07:23 +0000)
committerGavin Sherry <swm@php.net>
Sat, 12 Jan 2002 07:23:35 +0000 (07:23 +0000)
ext/dba/dba_db2.c

index 75cc7c18b98b6431c12d33d5f7eba6880a1dd1bc..37973ed3f932b913760b09e784125afcda3696e3 100644 (file)
@@ -47,13 +47,15 @@ DBA_OPEN_FUNC(db2)
        int gmode = 0;
        int filemode = 0644;
        struct stat check_stat;
-       
+       int ret;
+       int s = VCWD_STAT(info->path, &check_stat);
        type =  info->mode == DBA_READER ? DB_UNKNOWN :
                info->mode == DBA_TRUNC ? DB_BTREE :
-               VCWD_STAT(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN;
+               s ? DB_BTREE : DB_UNKNOWN;
          
        gmode = info->mode == DBA_READER ? DB_RDONLY :
-               info->mode == DBA_CREAT  ? DB_CREATE : 
+               (info->mode == DBA_CREAT && s) ? DB_CREATE : 
+               (info->mode == DBA_CREAT && !s) ? 0 :
                info->mode == DBA_WRITER ? 0         : 
                info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
 
@@ -65,11 +67,13 @@ DBA_OPEN_FUNC(db2)
                filemode = Z_LVAL_PP(info->argv[0]);
        }
 
-       if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) {
+       if(!(ret = db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp))) {
                info->dbf = malloc(sizeof(dba_db2_data));
                memset(info->dbf, 0, sizeof(dba_db2_data));
                ((dba_db2_data *) info->dbf)->dbp = dbp;
                return SUCCESS;
+       } else {
+               printf("Failed: type = %i\ngmode = %i\n%s\n",type,gmode,strerror(ret));
        }
        return FAILURE;
 }