ST::string filenameConvert(const ST::string& filename, eDirection dir) { if (dir == kRepack) { fputs("Zrax broke me!\n", stderr); abort(); } ST::string newName = filename; ST_ssize_t dotLoc = newName.find_last('.'); if (dotLoc < 0) { newName += (dir == kCreate) ? ".prp" : ".prd"; } else if (dir == kCreate) { ST::string ext = newName.substr(dotLoc); if (ext == ".prd") newName.replace(".prd", ".prp"); else if (ext != ".prp") newName += ".prp"; } else { ST::string ext = newName.substr(dotLoc); if (ext == ".prp") newName.replace(".prp", ".prd"); else if (ext != ".prd") newName += ".prd"; } return newName; }
static ST::string xmlEscape(const ST::string& text) { return text.replace("&", "&").replace("\"", """) .replace("<", "<").replace(">", ">") .replace("'", "'"); }