// Execute determins if a file or folder has to be copied an triggers the apropiate copy operation
Execute determins if a file or folder has to be copied an triggers the apropiate copy operation
// Execute determins if a file or folder has to be copied an triggers the apropiate copy operation
func (copy Copy) Execute() (result model.Result) {
	m := fmt.Sprintf("Copy %s to %s", copy.Source, copy.Destination)
	fmt.Println(m)
	log.Print(m)
	var err error
	fileInfo, err := os.Stat(copy.Source)
	if err != nil {
		result.WasSuccessful = false
		result.Message = err.Error()
		return result
	}
	switch mode := fileInfo.Mode(); {
	case mode.IsDir():
		err = dir(copy.Source, copy.Destination)
	case mode.IsRegular():
		err = file(copy.Source, copy.Destination)
	}
	if err != nil {
		result.WasSuccessful = false
		result.Message = err.Error()
		return result
	}
	result.WasSuccessful = true
	result.Message = fmt.Sprintf("Copied %s to %s", copy.Source, copy.Destination)
	return result
}
func ( copy Copy ) Execute ( ) ( result model . Result ) { m := fmt . Sprintf ( " " , copy . Source , copy . Destination ) fmt . Println ( m ) log . Print ( m ) var err error fileInfo , err := os . Stat ( copy . Source ) if err != nil { result . WasSuccessful = false result . Message = err . Error ( ) return result } switch mode := fileInfo . Mode ( ) ; { case mode . IsDir ( ) : err = dir ( copy . Source , copy . Destination ) case mode . IsRegular ( ) : err = file ( copy . Source , copy . Destination ) } if err != nil { result . WasSuccessful = false result . Message = err . Error ( ) return result } result . WasSuccessful = true result . Message = fmt . Sprintf ( " " , copy . Source , copy . Destination ) return result }
Execute determins if a file or folder has to be copied an triggers the apropiate copy operation
Execute determins if a file or folder has to be copied an triggers the apropiate copy operation