fix throwing error while creating dirs when path is ended with slash