I need to split a path by head/*tail.

Ex.

    File.head_tail_split('home/foo/bar')  #=> [ 'home', 'foo/bar' ]

Sure, I can write a clumsy loop like the following:

  def File.head_tail_split(fname)
    s = fname
    t = []
    h = nil
    until s == '.'
      t << h
      s, h = *split(s)
    end
    return h, File.join(*t.compact)
  end

But I'm betting there's a better way. Or maybe there's already an easy
way I'm overlooking?

T.