bbash/command/touch/touch.go
Tobias P.L Wennberg 15eeadf5d3 initial
2025-01-10 13:29:56 +01:00

28 lines
474 B
Go

package touch
import (
"bbash/environment"
"bbash/input_parser"
"fmt"
"os"
"path/filepath"
)
func Touch(in input_parser.Input, env *environment.Env) {
file_path := filepath.Join(env.Path, in.Args)
_, err := os.Stat(file_path)
if !os.IsNotExist(err) {
fmt.Print(fmt.Sprintf("File alredy exist!"))
return
}
file, err := os.Create(file_path)
if err != nil {
fmt.Print(fmt.Sprintf("Error creating file: %s", err.Error()))
return
}
defer file.Close()
}