Don't allow one char scheme names in File(Uri) #922
brian
17 Jan 2010
File is immutable, so normalize returns a new file. If you want to keep the normalized instance then assign it back to a.
fury
17 Jan 2010
Yes, but why is it changing drives? And why doesn't it walk the directory?
brian
17 Jan 2010
File takes a URI, not a os path, so d: is a URI scheme like http:. If you want to construct a file with a OS path and not a URI then use sys::File.os
fury
17 Jan 2010
Thank you for the explanation.
brian
17 Jan 2010
Promoted to ticket #922 and assigned to brian
no problem
in fact that is probably a common enough problem to warrant a check in the File constructor to throw a meaningful error if you pass in a scheme that looks like a DOS drive letter
or maybe better I'll just require that if you pass a scheme it must be "file:"
brian
17 Jan 2010
Renamed from Is this behaviour normal? to Don't allow one char scheme names in File(Uri)
fury
17 Jan 2010
Yeah, great idea. Maybe put that as the exception's message?
brian
21 Jan 2010
Ticket resolved in 1.0.49
Now File.make will throw ArgErr if the Uri passed has a non-null scheme other than "file:".
fury
22 Jan 2010
Thanks boss :)
fury
17 Jan 2010
a := File(`d:/fantom/`) echo(a.normalize) // this prints file:/C:/fantom a.walk |f| { // this only prints d:/fantom echo(f) }I find this to be a little strange. A call to normalize on a turns d:/fantom into file:/C:/fantom/ , and trying to walk the d:/fantom directory, which exists, only prints out d:/fantom . If however, I turn a into file:/d:/fantom everything works normal. Is there something I'm missing?