Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
static ST::string xmlEscape(const ST::string& text) {
    return text.replace("&", "&amp;").replace("\"", "&quot;")
               .replace("<", "&lt;").replace(">", "&gt;")
               .replace("'", "&apos;");
}