コード例 #1
0
ファイル: mixer.go プロジェクト: nmakiya/tritium
func (m *Mixer) Write(path string) (outputPath string, err error) {

	name := null.GetString(m.Name)
	version := null.GetString(m.Version)
	outputPath = filepath.Join(path, name+"-"+version+".mxr")

	bytes, err := pb.Marshal(m)
	if err != nil {
		return
	}

	bytes = crypto.Encrypt(bytes)

	err = os.MkdirAll(path, fileutil.DIR_PERMS)
	if err != nil {
		return
	}

	err = ioutil.WriteFile(outputPath, bytes, fileutil.FILE_PERMS)
	if err != nil {
		return
	}

	return
}
コード例 #2
0
ファイル: output.go プロジェクト: nmakiya/tritium
func (pkg *Package) write() {
	//	path, name := filepath.Split(pkg.location)
	//	path, name := filepath.Split(pkg.LoadPath)
	//	outputFilename := filepath.Join(path, name, name+".tpkg")
	name := null.GetString(pkg.Name)
	outputFilename := filepath.Join(pkg.LoadPath, name+".tpkg")

	bytes, err := proto.Marshal(pkg.Package)

	if err != nil {
		panic("Could not marshal package: " + name + " (" + err.Error() + ")")
	}

	bytes = crypto.Encrypt(bytes)

	ioutil.WriteFile(outputFilename, bytes, os.FileMode(0666))
	pkg.OutputFile = outputFilename

	pkg.Println(" -- output: " + outputFilename)
}