Esempio n. 1
0
File: file.go Progetto: Andals/gpm
func (this *File) Write(msg []byte) (int, error) {
	// file may be deleted when doing logrotate
	if !misc.FileExist(this.path) {
		this.File, _ = openFile(this.path)
	}

	return this.File.Write(msg)
}
Esempio n. 2
0
File: file.go Progetto: Andals/gobox
func (this *File) Write(msg []byte) (int, error) {
	// file may be deleted when doing logrotate
	if !misc.FileExist(this.path) {
		this.Close()
		this.File, _ = openFile(this.path)
	}

	<-this.lockCh
	n, err := this.File.Write(msg)
	this.lockCh <- 1

	return n, err
}
Esempio n. 3
0
func ParsePackageConf(prjHome string) (*PackageConf, *exception.Exception) {
	confPath := getPackageJsonPath(prjHome)
	if !misc.FileExist(confPath) {
		return nil, exception.New(errno.E_CONF_PACKAGE_JSON_NOT_EXISTS, "There is no "+PACKAGE_JSON+" in "+prjHome)
	}

	var pkgJson packageJson

	jsonStr, _ := ioutil.ReadFile(confPath)
	err := json.Unmarshal(jsonStr, &pkgJson)
	if nil != err {
		return nil, exception.New(errno.E_CONF_PACKAGE_JSON_PARSE_ERROR, "Parse "+PACKAGE_JSON+" error")
	}

	return parseByJson(prjHome, &pkgJson)
}