Refactor files function

This prevents double slashes if `src` ends with a slash.