本文整理汇总了Golang中github.com/uwedeportivo/romba/types.Dat.Description方法的典型用法代码示例。如果您正苦于以下问题:Golang Dat.Description方法的具体用法?Golang Dat.Description怎么用?Golang Dat.Description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/uwedeportivo/romba/types.Dat
的用法示例。
在下文中一共展示了Dat.Description方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dir2dat
func (rs *RombaService) dir2dat(cmd *commander.Command, args []string) error {
outpath := cmd.Flag.Lookup("out").Value.Get().(string)
if err := os.MkdirAll(outpath, 0777); err != nil {
return err
}
srcpath := cmd.Flag.Lookup("source").Value.Get().(string)
srcInfo, err := os.Stat(srcpath)
if err != nil {
return err
}
if !srcInfo.IsDir() {
return fmt.Errorf("%s is not a directory", srcpath)
}
dat := new(types.Dat)
dat.Name = cmd.Flag.Lookup("name").Value.Get().(string)
dat.Description = cmd.Flag.Lookup("description").Value.Get().(string)
err = archive.Dir2Dat(dat, srcpath, outpath)
if err != nil {
return err
}
fmt.Fprintf(cmd.Stdout, "dir2dat successfully completed a DAT in %s for directory %s", outpath, srcpath)
return nil
}
示例2: BuildDat
func (depot *Depot) BuildDat(dat *types.Dat, outpath string) (bool, error) {
datPath := filepath.Join(outpath, dat.Name)
err := os.Mkdir(datPath, 0777)
if err != nil {
return false, err
}
var fixDat *types.Dat
for _, game := range dat.Games {
fixGame, err := depot.buildGame(game, datPath)
if err != nil {
return false, err
}
if fixGame != nil {
if fixDat == nil {
fixDat = new(types.Dat)
fixDat.Name = dat.Name
fixDat.Description = dat.Description
fixDat.Path = dat.Path
}
fixDat.Games = append(fixDat.Games, fixGame)
}
}
if fixDat != nil {
fixDatPath := filepath.Join(outpath, fixPrefix+dat.Name+datSuffix)
fixFile, err := os.Create(fixDatPath)
if err != nil {
return false, err
}
defer fixFile.Close()
fixWriter := bufio.NewWriter(fixFile)
defer fixWriter.Flush()
err = types.ComposeDat(fixDat, fixWriter)
if err != nil {
return false, err
}
}
return fixDat == nil, nil
}
示例3: BuildDat
func (depot *Depot) BuildDat(dat *types.Dat, outpath string, numSubworkers int, deduper dedup.Deduper) (bool, error) {
datPath := filepath.Join(outpath, dat.Name)
err := os.Mkdir(datPath, 0777)
if err != nil {
return false, err
}
fixDat := new(types.Dat)
fixDat.FixDat = true
fixDat.Name = "fix_" + dat.Name
fixDat.Description = dat.Description
fixDat.Path = dat.Path
fixDat.UnzipGames = dat.UnzipGames
wc := make(chan *types.Game)
erc := make(chan error)
closeC := make(chan bool)
mutex := new(sync.Mutex)
for i := 0; i < numSubworkers; i++ {
gb := new(gameBuilder)
gb.depot = depot
gb.wc = wc
gb.erc = erc
gb.mutex = mutex
gb.datPath = datPath
gb.fixDat = fixDat
gb.index = i
gb.deduper = deduper
gb.closeC = closeC
go gb.work()
}
var minionErr error
endLoop:
for _, game := range dat.Games {
select {
case wc <- game:
case err := <-erc:
minionErr = err
break endLoop
}
}
close(wc)
finishedSubworkers := 0
endLoop2:
for {
glog.V(4).Infof("builder master: finished so far %d", finishedSubworkers)
select {
case <-closeC:
glog.V(4).Infof("builder master: finished another subworker")
finishedSubworkers++
if finishedSubworkers == numSubworkers {
break endLoop2
}
case err := <-erc:
glog.V(4).Infof("builder master: minion error")
minionErr = err
}
}
if minionErr != nil {
return false, minionErr
}
if len(fixDat.Games) > 0 {
fixDatPath := filepath.Join(outpath, fixPrefix+dat.Name+datSuffix)
fixFile, err := os.Create(fixDatPath)
if err != nil {
return false, err
}
defer fixFile.Close()
fixWriter := bufio.NewWriter(fixFile)
defer fixWriter.Flush()
err = types.ComposeCompliantDat(fixDat, fixWriter)
if err != nil {
return false, err
}
}
return len(fixDat.Games) > 0, nil
}