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?
brianSun 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.
furySun 17 Jan 2010
Yes, but why is it changing drives? And why doesn't it walk the directory?
brianSun 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
furySun 17 Jan 2010
Thank you for the explanation.
brianSun 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:"
brianSun 17 Jan 2010
Renamed from Is this behaviour normal? to Don't allow one char scheme names in File(Uri)
furySun 17 Jan 2010
Yeah, great idea. Maybe put that as the exception's message?
brianThu 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 Sun 17 Jan 2010
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?
brian Sun 17 Jan 2010
File is immutable, so
normalize
returns a new file. If you want to keep the normalized instance then assign it back toa
.fury Sun 17 Jan 2010
Yes, but why is it changing drives? And why doesn't it walk the directory?
brian Sun 17 Jan 2010
File takes a URI, not a os path, so
d:
is a URI scheme likehttp:
. If you want to construct a file with a OS path and not a URI then usesys::File.os
fury Sun 17 Jan 2010
Thank you for the explanation.
brian Sun 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 Sun 17 Jan 2010
Renamed from Is this behaviour normal? to Don't allow one char scheme names in File(Uri)
fury Sun 17 Jan 2010
Yeah, great idea. Maybe put that as the exception's message?
brian Thu 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 Fri 22 Jan 2010
Thanks boss :)