Ejemplo n.º 1
0
string getOFRelPath(string from){
    Poco::Path base(true);
    base.parse(from);

    Poco::Path path;
    path.parse( getOFRoot() );
    path.makeAbsolute();

    
    cout << "getOFRelPath " << base.toString() << " " << path.toString() << endl;
    
	string relPath;
	if (path.toString() == base.toString()){
		// do something.
	}

	int maxx = MAX(base.depth(), path.depth());
	for (int i = 0; i <= maxx; i++){

		bool bRunOut = false;
		bool bChanged = false;
		if (i <= base.depth() && i <= path.depth()){
			if (base.directory(i) == path.directory(i)){

			} else {
				bChanged = true;
			}
		} else {
			bRunOut = true;
		}
		if (bRunOut == true || bChanged == true){
			for (int j = i; j <= base.depth(); j++){
				relPath += "../";
			}
			for (int j = i; j <= path.depth(); j++){
				relPath += path.directory(j) + "/";
			}
			break;
		}
	}
    
    cout << relPath << " ---- " << endl;
    
    
    return relPath;
}