示例#1
0
文件: file.go 项目: calj/kaigara
func CreateDir(dirname string) {
	if Exists(dirname) {
		term.Error("directory '" + dirname + "' already exists")
	} else {
		err := os.Mkdir(dirname, 0755)

		if err != nil {
			term.Error(err.Error())
		} else {
			term.Create(dirname)
		}
	}
}
示例#2
0
文件: file.go 项目: calj/kaigara
func CreateFile(filename string) {
	if Exists(filename) {
		term.Error("file '" + filename + "' already exists")
	} else {
		file, err := os.Create(filename)

		if err != nil {
			term.Error(err.Error())
		} else {
			term.Create(filename)
		}

		defer file.Close()
	}
}