示例#1
0
cxStream cxMp3StreamCreate(cxConstChars file)
{
    cxMp3Stream this = CX_CREATE(cxMp3Stream);
    cxString path = cxAssetsPath(file);
    CX_RETAIN_SWAP(this->path, path);
    return (cxStream)this;
}
示例#2
0
static void cxHashRootReadDB(cxDBEnv env,cxHashRoot root,xmlTextReaderPtr reader)
{
    cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, root, env);
    int depth = xmlTextReaderDepth(reader);
    while(xmlTextReaderRead(reader) && depth != xmlTextReaderDepth(reader)){
        if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
            continue;
        }
        cxConstChars temp = cxXMLReadElementName(reader);
        if(!ELEMENT_IS_TYPE(cxDB)){
            continue;
        }
        cxConstChars file = cxXMLAttr(reader,"file");
        cxConstChars table = cxXMLAttr(reader,"table");
        cxConstChars type = cxXMLAttr(reader,"type");
        cxConstChars sid = cxXMLAttr(reader,"id");
        cxConstChars path = cxXMLAttr(reader,"path");
        //assert file copy ->to document
        cxBool copy = cxXMLReadBoolAttr(info, "copy", false);
        if(copy && file != NULL){
            cxCopyFile(file, NULL, NULL);
        }
        cxBool rdonly = cxXMLReadBoolAttr(info,  "rdonly", false);
        if(sid == NULL){
            CX_WARN("db id not set,will can't add dataset");
        }
        cxString sfile = NULL;
        if(cxConstCharsEqu(path, "assert")){
            sfile = cxAssetsPath(file);
            //assert must set true
            rdonly = true;
        }else if(cxConstCharsEqu(path, "document")){
            sfile = cxDocumentPath(file);
        }else{
            CX_ERROR("must set path assert or document");
        }
        cxAny db = NULL;
        if(file != NULL && table != NULL && type != NULL){
            db = cxDBCreate(env, cxStringBody(sfile), table, type, rdonly);
        }
        if(db != NULL && sid != NULL){
            cxHashSet(root->items, cxHashStrKey(sid), cxDBTypesCreate(db));
        }else{
            CX_ERROR("open dbenv type %s,db %s:%s failed",cxStringBody(env->type),file,table);
        }
    }
}