A few thoughts about KUrl

Jarosław Staniek js at iidea.pl
Thu Dec 21 17:24:20 GMT 2006


Leonardo Stern said the following, On 2006-12-21 17:19:

>>How about using "%3A" instead of ':' ?
>>Then we'd have no problem in places where ':' is considered as a separator.
>>Assume nobody should win32-specific absolute paths ("c:/") in portable code.
>>
>>Let's see whether this could work...
>>
>> > Should KUrl("/") act as a relative path on windows ? (
>> > KUrl("file:///C:/foo/bar") + KUrl("/") = KUrl("file:///C:/") , similar
>> > to "cd /" in windows console)
>>
>>Wouldn't using this side effect make the code unportable?
> 
> 
> Not at all. In linux, we have only one root dir, in Windows, one for
> each drive letter.
> If "file:////" works on linux (did't check yet), must also works on Windows
> 
> 1 - "file:///" can reffer to root of the current unit (drive letter)
> [root in linux].

OK, if you specify the current dir directly before you execute cd("/") - see 
[1] below.
The term "current" is tricky and may cause random results. Look at a part of a 
program that changes the current dir.
This looks OK for us on non-win32 since we're not depending on 'current dir' 
information at all -- cd("/") operates on absolute path.
On win32 for your semantic, unless you use:

[1]   KUrl("file:///c:/foo/bar").cd("/"))

..simple calls like cd("/") can return any local or network drive.
I encountered hard to hunt bugs related to this...

> For portability : KUrl("file:///c:/foo/bar").cd("/") ==
> KUrl("file:///") == KUrl("file://c:/")
> In this case, "/" point to QDir::rootPath()  == "c:/"

> 
> 2 - "file:///" can reffer to a virtual root that contains all drive
> letters [root in linux] (as seen in Opera)

This one is well defined and pretty well known.

I also dont know whether you're talking about using slashes in the code or 
also in the GUI's line edits. In the latter case no single Joe user expects 
entering '/' will work on win32 (but can be a nice extension, already provided 
by Qt). For sure, in the native win32 file dialogs, entering '\' does indeed 
move us to the root of the current drive. So this is a deeper rule, not only a 
feature of the win32 shell.

-- 
regards / pozdrawiam, Jaroslaw Staniek
  Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
  Kexi & KOffice: http://www.kexi-project.org, http://www.koffice.org
  KDE3 & KDE4 Libraries for MS Windows: http://kdelibs.com, http://www.kde.org




More information about the kde-core-devel mailing list