
# Splits a file path into an array of individual path components.
# This differs from <tt>File.split</tt>, which divides the path into
# only two parts, directory path and basename.
#
#   split_all("a/b/c") =>  ['a', 'b', 'c']
#
def File.split_all(path)
  head, tail = File.split(path)
  return [tail] if head == '.' || tail == '/'
  return [head, tail] if head == '/'
  return split_all(head) + [tail]
end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCFile < Test::Unit::TestCase

    def test_split_all
      fp = "this/is/test"
      assert_equal( ['this', 'is', 'test'], File.split_all(fp) )
    end

  end

=end
