cpr("/path/to/dir/", "/dest/")
//-> copies contents of /path/to/dir/ into /dest/
cpr("/path/to/dir/**/*", "/dest/")
//-> same as above
cpr("/path/**/dir/", "/dest/")
//-> same, and possibly more if there're other nested dirs named "dir"
When/if globexpands directories, we can use glob.Glob to copy each file as it is expanded from the glob. This is not only better because it helps avoid race conditions by copying the file immediately after it's expanded, but it may also have better performance because the hard drive has already sought to that track/sector.
Since a glob will likely resolve to many files, we might as well implement #41 along with this. An instance of glob.Glob per glob and file paths memoized to avoid redundancy.
cpr(["/path/to/dir/", "/path/to/dir/**/*", "/path/**/dir/"], "/dest/")
//-> same as above, with no file copied more than once
When/if
glob
expands directories, we can useglob.Glob
to copy each file as it is expanded from the glob. This is not only better because it helps avoid race conditions by copying the file immediately after it's expanded, but it may also have better performance because the hard drive has already sought to that track/sector.Since a glob will likely resolve to many files, we might as well implement #41 along with this. An instance of
glob.Glob
per glob and file paths memoized to avoid redundancy.