Beispiel #1
0
MString MUrl::url()
{
    // url = scheme + path + query
    MString ret = host() + path();
    ret.replace("//", "/");
    ret = scheme() + "://" + ret;

    return ret;
}
Beispiel #2
0
int MUrl::parseQuery()
{
    MString queryStr = m_query;
    queryStr.replace("?", "&");
    MStringList query = queryStr.split("&");
    for (unsigned int i = 0; i < query.size(); ++i) {
        MString &frag = query[i];
        MStringList kv = frag.split("=");
        if (kv.size() > 1) {
            m_queryField[kv.at(0)] = kv.at(1);
        }
    }

    return 0;
}
Beispiel #3
0
bool MDir::createDir(const MString &dirName)
{
    // process multi "//" to one "/"
    MString dn = dirName;
    dn.push_back('/');
    dn.replace("//", "/");

    int index = dn.startWith("/") ? 1 : 0;
    for (unsigned int i = index; i < dn.size(); ++i) {
        char &c = dn[i];

        if (c == '/') {
            c = '\0';
            int ret = access(dn.c_str(), F_OK);
            if (ret == 0) {
                c = '/';
                continue;
            }

            ret = mkdir(dn.c_str(), 0744);
            if (ret == 0) {
                c = '/';
                continue;
            }

//            if (errno == ENOENT) {
//                ret = mkdir(dn.c_str(), 0744);
//                if (ret == 0) {
//                    continue;
//                }
//            }

            merrno = errno;
            return false;
        }
    }

    return true;
}