Canonical File Path in Ruby

Viewed 9040

Is there an easy way in Ruby to find a canonical file path out of a messy file path?

For example:

  • a/b/../c/x is the same as a/c/x
  • a/./b/c/x is the same as a/b/c/x
  • a/./b/../../c/x is the same as c/x

Any simple way to do this?

2 Answers
Related