Ensure directory is present before building a file rule.

This avoids either manually creating directories, or obscure errors
when R can't save a file to a place.  Possibly this should be a
configurable behaviour, but we're guaranteed to be working with
genuine files so this should be harmless.
Can specify whole directory in sources list

Will read all files that end in .R or .r
Pulled this out of its own function to avoid clashes with testthat's
source_dir (though that's only a potential issue using devtools).