package engine

import (
	"bufio"
	"fmt"
	"os"
)

func removeFolders(folders []string) error {
	for _, folder := range folders {
		if err := os.RemoveAll(folder); err != nil {
			if os.IsNotExist(err) { //If it doesn't exist that is fine, we would delete it anyway
				continue
			} else {
				fmt.Printf("Error removing %s folder, error: %s exiting...", folder, err)
				bufio.NewReader(os.Stdin).ReadBytes('\n')
				os.Exit(1)
			}
		}
		fmt.Println("Removed Folder: ", folder)
	}
	return nil
}

func removeFiles(files []string) error {
	for _, file := range files {
		if err := os.Remove(file); err != nil {
			if os.IsNotExist(err) { //If it doesn't exist that is fine, we would delete it anyway
				continue
			} else {
				fmt.Printf("Error removing %s file, error: %s exiting...", file, err)
				bufio.NewReader(os.Stdin).ReadBytes('\n')
				os.Exit(1)
			}
		}
		fmt.Println("Removed file: ", file)
	}
	return nil
}
