cpr icon indicating copy to clipboard operation
cpr copied to clipboard

Globs

Open stevenvachon opened this issue 8 years ago • 1 comments

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 glob expands 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

stevenvachon avatar Dec 22 '16 22:12 stevenvachon

cpy and its underlying cp-file both do this.

stevenvachon avatar Mar 16 '19 17:03 stevenvachon