diff -r 677e702c5863 -r a33a2bdd8299 misc.cpp --- a/misc.cpp Fri Aug 19 07:42:32 2005 +0000 +++ b/misc.cpp Tue Aug 30 14:09:19 2005 +0000 @@ -81,35 +81,45 @@ QString s=src; QString d=dst; int i; - // Find relative path from src to dst - // Remove the first "/" - if (s.section ("/",0,0).isEmpty()) + if (s==d) { - s=s.right (s.length()-1); - d=d.right (d.length()-1); - } - - // remove identical left parts - while (s.section("/",0,0) == d.section("/",0,0) ) + // Special case, we just need the name of the file, + // not the complete path + i=d.findRev ("/"); + d=d.right (d.length()-i-1); + } else { - i=s.find ("/"); - s=s.right (s.length()-i-1); - d=d.right (d.length()-i-1); - } + // Find relative path from src to dst - int srcsep=s.contains("/"); - int dstsep=d.contains("/"); - if (srcsep >= dstsep ) - { - // find path to go up first and then back to dst - i=1; - while (i<=srcsep) + // Remove the first "/" + if (s.section ("/",0,0).isEmpty()) { - d="../"+d; - i++; - } - } + s=s.right (s.length()-1); + d=d.right (d.length()-1); + } + + // remove identical left parts + while (s.section("/",0,0) == d.section("/",0,0) ) + { + i=s.find ("/"); + s=s.right (s.length()-i-1); + d=d.right (d.length()-i-1); + } + + int srcsep=s.contains("/"); + int dstsep=d.contains("/"); + if (srcsep >= dstsep ) + { + // find path to go up first and then back to dst + i=1; + while (i<=srcsep) + { + d="../"+d; + i++; + } + } + } return d; }