Use [base|dir]name() that don't modify argument.

The version on Ubuntu Lucid does.