| 293 | } |
| 294 | #if USE_S3 |
| 295 | std::vector<std::string> s3GetFileNamesFromXml(const char* fbuf, int fsize, const xmlChar* nspace, const xmlChar* uri, const xmlChar* xpathExpr,std::string& prefix) |
| 296 | { |
| 297 | std::vector<std::string> files; |
| 298 | // get xml |
| 299 | xmlDocPtr doc = xmlParseMemory(fbuf,fsize); |
| 300 | // create context |
| 301 | xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc); |
| 302 | // register namespace |
| 303 | if(xmlXPathRegisterNs(xpathCtx,nspace,uri)==0){ |
| 304 | // execute xpath |
| 305 | xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); |
| 306 | if(!xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)){ |
| 307 | xmlNodeSetPtr nodes=xpathObj->nodesetval; |
| 308 | for (int i=0; i < nodes->nodeNr; i++) { |
| 309 | xmlChar* str = xmlNodeListGetString(doc, nodes->nodeTab[i]->xmlChildrenNode, 1); |
| 310 | std::string file((char *)str); |
| 311 | //make sure only files |
| 312 | if(file.length()>prefix.length()+1 && file.find('/',prefix.length()+1)==std::string::npos) |
| 313 | files.push_back(file); |
| 314 | xmlFree(str); |
| 315 | } |
| 316 | } |
| 317 | xmlXPathFreeObject(xpathObj); |
| 318 | } |
| 319 | xmlXPathFreeContext(xpathCtx); |
| 320 | xmlFreeDoc(doc); |
| 321 | return files; |
| 322 | } |
| 323 | #endif // USE_S3 |
| 324 | |
| 325 | |