Also, checking for '.' is wrong. "foo" and "foo/bar" are also relative paths. You need to check for leading /.