25 lines
474 B
Go
25 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[0])
|
|
_, 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()
|
|
}
|