bbash/command/touch/touch.go
2025-01-13 10:14:36 +01:00

25 lines
475 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_raw)
_, 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()
}