Refactor files function

This prevents double slashes if `src` ends with a slash.
I think it’s more readable.