From: "ara.t.howard" Date: 2008-07-29T00:27:51+09:00 Subject: Re: head/tail split for path On Jul 28, 2008, at 5:39 AM, Phlip wrote: > In the new system we follow a simple rule: If it's a filename, > relative path, or absolute path of any kind, it's a Pathname. This > allows us to stay within the Pathname feature set, and manipulate > paths without any string surgery. The result is much more typesafe. > > In theory, Pathnames would be safer if you needed to support \ path > delimiters, and if you needed to support paths with embedded \ or / > characters. We are very good string surgeons, so we never had those > problems. i've had the same experience. this only issue is cfp:~ > ruby -r pathname -e' Pathname.new("does-not-exist").realpath ' /opt/local/lib/ruby/1.8/pathname.rb:420:in `lstat': No such file or directory - /Users/ahoward/does-not-exist (Errno::ENOENT) from /opt/local/lib/ruby/1.8/pathname.rb:420:in `realpath_rec' from /opt/local/lib/ruby/1.8/pathname.rb:453:in `realpath' from -e:1 which is to say that certain pathname operations blow up when files do not exist so code must work with that fact. also, pathnames cannot be given to many functions that expect strings so you end up with a lot of 'pathname.to_s' lines in the code. that said, using pathname will result in better code every time because it deals with the common errors people make slinging strings as path components. cheers. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama