[QBS] FileInfo relativePath function
Сергей Лопатин
magist3r at gmail.com
Thu Sep 13 18:35:38 CEST 2012
Hi there!
I found strange issue in qbs fileinfo module:
function relativePath(base, rel)
{
var basel = base.split('/');
var rell = rel.split('/');
var i = 0;
while (i < basel.length && i < rell.length && basel[i] == rell[i])
i++;
var j = i;
var r = [];
for (; i < basel.length; i++) // i really don't understand why we
need this line
r.push('..');
for (; j < rell.length; j++)
r.push(rell[j]);
return r.join('/');
}
I get some unexpected results:
print(FileInfo.relativePath(".","data/webview/terminator.png"));
../data/webview/terminator.png
print(FileInfo.relativePath("data/","data/webview/terminator.png"));
../webview/terminator.png
print(FileInfo.relativePath("data","data/webview/terminator.png")); //
works fine
webview/terminator.png
I don't understand why this function returns '../'.I could just delete
these lines:
for (; i < basel.length; i++)
r.push('..');
but not sure if it's right and not break anything :)
Regards,
Sergei.
More information about the Qbs
mailing list