@@ -38,14 +38,14 @@ func FolderExists(foldername string) bool {
3838 return info .IsDir ()
3939}
4040
41- // FilesInFolder returns the files contains in the provided folder
41+ // FilesInFolder returns the filepath contains in the provided folder
4242func FilesInFolder (dir , filename string ) ([]string , error ) {
4343 if ! FolderExists (dir ) {
4444 return nil , errors .New (dir + " folder does not exist" )
4545 }
4646 var files []string
4747 err := filepath .Walk (dir , func (path string , f os.FileInfo , err error ) error {
48- if ! f .IsDir () && strings .Contains (path , filename ) {
48+ if ! f .IsDir () && strings .HasSuffix (path , filename ) {
4949 files = append (files , path )
5050 }
5151 return err
@@ -63,17 +63,17 @@ func ReadFile(filename string) (string, error) {
6363// skip the file if you don't want to copy
6464func CopyDir (src , dst , skip string ) error {
6565 s := cp.Options {Skip : func (src string ) (bool , error ) {
66- return strings .Contains (strings .ToLower (src ), skip ), nil
66+ return strings .HasSuffix (strings .ToLower (src ), skip ), nil
6767 }}
6868 return cp .Copy (src , dst , s )
6969}
7070
71- // CopyDirContains copies the directory from the source to the destination
72- // contain is the file if you want to copy
73- func CopyDirContains (src , dst , contain string ) error {
71+ // CopyDirHasSuffix copies the directory from the source to the destination
72+ // contain is the file if you want to copy, and rename copied filename with dir/index_filename
73+ func CopyDirHasSuffix (src , dst , suffix string ) error {
7474 var filelist []string
7575 err := filepath .Walk (src , func (path string , f os.FileInfo , err error ) error {
76- if ! f .IsDir () && strings .Contains (strings .ToLower (f .Name ()), contain ) {
76+ if ! f .IsDir () && strings .HasSuffix (strings .ToLower (f .Name ()), suffix ) {
7777 filelist = append (filelist , path )
7878 }
7979 return err
0 commit comments