This is a multi-part message in MIME format.
--------------7CB8B9B2A59F5210BC685C87
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


I added a File.extension method to file.c.
I was going to add a 'rootname' which is like
basename, but strips off the extension also,
but while I was in the code, I noticed the nice
wild-card available.

A patch file is attached, along with a little test script.

--
Mike Hall
http://www.enteract.com/~mghall
--------------7CB8B9B2A59F5210BC685C87
Content-Type: application/x-patch;
 nameile.patch"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filenameile.patch"

KioqIGZpbGUuYy5vcmlnCVRodSBBcHIgIDQgMjM6NTU6MDMgMjAwMgotLS0gZmlsZS5jCVRo
dSBBcHIgIDQgMjM6NTM6MzIgMjAwMgoqKioqKioqKioqKioqKioKKioqIDE2MzMsMTYzOCAq
KioqCi0tLSAxNjMzLDE2NjAgLS0tLQogIH0KICAKICBzdGF0aWMgVkFMVUUKKyByYl9maWxl
X3NfZXh0ZW5zaW9uKGtsYXNzLCBmbmFtZSkKKyAgICAgVkFMVUUga2xhc3MsIGZuYW1lOwor
IHsKKyAgICAgY2hhciAqbmFtZSwgKnAsICplOworICAgICBWQUxVRSBleHQ7CisgCisgICAg
IG5hbWUgPSBTVFIyQ1NUUihmbmFtZSk7CisgICAgIHAgPSBzdHJyZGlyc2VwKG5hbWUpOwkv
KiBnZXQgdGhlIGxhc3QgcGF0aCBjb21wb25lbnQgKi8KKyAgICAgaWYgKCFwKQorIAlwID0g
bmFtZTsKKyAgICAgZWxzZQorIAlwKys7CisgCisgICAgIGUgPSBzdHJyY2hyKHAsICcuJyk7
CS8qIGdldCB0aGUgbGFzdCBkb3Qgb2YgdGhlIGxhc3QgY29tcG9uZW50ICovCisgICAgIGlm
ICghZSB8fCBlID09IHApCQkvKiBubyBkb3QsIG9yIHRoZSBvbmx5IGRvdCBpcyBmaXJzdD8g
Ki8KKyAJcmV0dXJuIHJiX3N0cl9uZXcyKCIiKTsKKyAgICAgZXh0ID0gcmJfc3RyX25ldzIo
ZSk7CS8qIGtlZXAgdGhlIGRvdCwgdG9vISAqLworICAgICBpZiAoT0JKX1RBSU5URUQoZm5h
bWUpKSBPQkpfVEFJTlQoZXh0KTsKKyAgICAgcmV0dXJuIGV4dDsKKyB9CisgCisgc3RhdGlj
IFZBTFVFCiAgcmJfZmlsZV9zX3NwbGl0KGtsYXNzLCBwYXRoKQogICAgICBWQUxVRSBrbGFz
cywgcGF0aDsKICB7CioqKioqKioqKioqKioqKgoqKiogMjU1OSwyNTY0ICoqKioKLS0tIDI1
ODEsMjU4NyAtLS0tCiAgICAgIHJiX2RlZmluZV9zaW5nbGV0b25fbWV0aG9kKHJiX2NGaWxl
LCAiZXhwYW5kX3BhdGgiLCByYl9maWxlX3NfZXhwYW5kX3BhdGgsIC0xKTsKICAgICAgcmJf
ZGVmaW5lX3NpbmdsZXRvbl9tZXRob2QocmJfY0ZpbGUsICJiYXNlbmFtZSIsIHJiX2ZpbGVf
c19iYXNlbmFtZSwgLTEpOwogICAgICByYl9kZWZpbmVfc2luZ2xldG9uX21ldGhvZChyYl9j
RmlsZSwgImRpcm5hbWUiLCByYl9maWxlX3NfZGlybmFtZSwgMSk7CisgICAgIHJiX2RlZmlu
ZV9zaW5nbGV0b25fbWV0aG9kKHJiX2NGaWxlLCAiZXh0ZW5zaW9uIiwgcmJfZmlsZV9zX2V4
dGVuc2lvbiwgMSk7CiAgCiAgICAgIHNlcGFyYXRvciA9IHJiX29ial9mcmVlemUocmJfc3Ry
X25ldzIoIi8iKSk7CiAgICAgIHJiX2RlZmluZV9jb25zdChyYl9jRmlsZSwgIlNlcGFyYXRv
ciIsIHNlcGFyYXRvcik7Cg--------------7CB8B9B2A59F5210BC685C87
Content-Type: text/plain; charset=us-ascii;
 nametest"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenametest"


# test 'File.extension' command

puts "Ruby: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" 
# Ruby: 1.7.2 (2002-03-27) [i686-linux] 

puts "FILE	DIR	BASE	FILE	EXT"

def show path
  d  ile.dirname path
  b  ile.basename path
  f  ile.basename path, '.*'
  e  ile.extension path
  puts "#{path}	#{d}	#{b}	#{f}	#{e}"
end

show 'a'
show 'a.'
show 'a.b'
show 'a.b/c'

show '/a'
show '/a.'
show '/a.b'
show '/a.b/c'

show '.a'
show '.a.'
show '.a.b'
show '.a/'
show '.a/.b'
show '.a/.b.'
show '.a/.b.c'
show '.a/b'
show '.a/b.'
show '.a/b.c'
show '.a/b.c.'
show '.a/b.c.d'


--------------7CB8B9B2A59F5210BC685C87--