JSBool db_collection_resolve( JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp ){ if ( flags & JSRESOLVE_ASSIGNING ) return JS_TRUE; Convertor c( cx ); string collname = c.toString( id ); if ( isSpecialName( collname ) ) return JS_TRUE; if ( obj == c.getGlobalPrototype( "DBCollection" ) ) return JS_TRUE; JSObject * proto = JS_GetPrototype( cx , obj ); if ( c.hasProperty( obj , collname.c_str() ) || ( proto && c.hasProperty( proto , collname.c_str() ) ) ) return JS_TRUE; string name = c.toString( c.getProperty( obj , "_shortName" ) ); name += "."; name += collname; jsval db = c.getProperty( obj , "_db" ); if ( ! JSVAL_IS_OBJECT( db ) ) return JS_TRUE; JSObject * coll = doCreateCollection( cx , JSVAL_TO_OBJECT( db ) , name ); c.setProperty( obj , collname.c_str() , OBJECT_TO_JSVAL( coll ) ); *objp = obj; return JS_TRUE; }
void gbGetOutputTmp(char *path, char *tmpPath) /* generate the tmp path name, moving the compress extension if needed */ { char savedExt[32]; int len; savedExt[0] = '\0'; strcpy(tmpPath, path); /* don't add extension for special names */ if (!isSpecialName(path)) { if (gbGetCompressor(tmpPath, "r") != NULL) { char *last = strrchr(tmpPath, '.'); strcpy(savedExt, last); *last = '\0'; } len = strlen(tmpPath); safef(tmpPath+len, PATH_LEN-len, ".%d.%s.tmp%s", getpid(), getHost(), savedExt); } }
JSBool db_resolve( JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp ){ if ( flags & JSRESOLVE_ASSIGNING ) return JS_TRUE; Convertor c( cx ); if ( obj == c.getGlobalPrototype( "DB" ) ) return JS_TRUE; string collname = c.toString( id ); if ( isSpecialName( collname ) ) return JS_TRUE; JSObject * proto = JS_GetPrototype( cx , obj ); if ( proto && c.hasProperty( proto , collname.c_str() ) ) return JS_TRUE; JSObject * coll = doCreateCollection( cx , obj , collname ); c.setProperty( obj , collname.c_str() , OBJECT_TO_JSVAL( coll ) ); *objp = obj; return JS_TRUE; }