/** * reads the mime file and retrieves the mime for a specific resource */ int mime_read(conf_s conf, const char *file, content_type ctype) { FILE *fd; char fbuf[PATH_MAX], buf[WCONF_MAX_LINE_BUF]; const char *word = fext(file); size_t len = strlen(word); size_t pos = 0; pathcat(conf.document_root, conf.mime, fbuf); if ((fd = fopen(fbuf, "r")) == 0) return -1; while(fgets(buf, WCONF_MAX_LINE_BUF, fd) != 0 && *ctype == 0) { // Remove newline remove_newline(buf); if (buf[0] != '#') { pos = strnmime(word, len, buf); if (pos) { strncpy(ctype, buf, pos); } } } fclose(fd); if (pos == 0) strncpy(ctype, "text/plain", 11); return 1; }
std::string TileAssembler::getDirEntryNameFromModName(unsigned int pMapId, const std::string& pModPosName) { size_t spos; char buffer[20]; std::string modelFileName = getModNameFromModPosName(pModPosName); //std::string fext = pModPosName.substr(modelFileName.length(),pModPosName.length()); unsigned int fextId = getUniqueNameId(pModPosName); sprintf(buffer, "_%07d",fextId); std::string fext(buffer); spos = modelFileName.find_last_of('/'); std::string fname = modelFileName.substr(spos+1, modelFileName.length()); spos = fname.find_last_of('.'); fname = fname.substr(0,spos); sprintf(buffer, "%03u", pMapId); std::string dirEntry(buffer); dirEntry.append("_"); dirEntry.append(fname); dirEntry.append(fext); dirEntry.append(".vmap"); return(dirEntry); }