Example #1
0
File: gen.go Project: eZanmoto/Bake
func (p *Project) genDirConts(dir *fs.Node, srcDir, tgtDir string) error {
	for _, node := range dir.Children() {
		src := path.Join(srcDir, node.Name())

		tgtName, err := p.dict.ExpandStr(node.Name())
		if err != nil {
			return err
		}
		tgt := path.Join(tgtDir, tgtName)

		if node.Children() == nil { // not a dir
			err = p.genFile(src, tgt)
		} else if err = p.genDir(tgt); err == nil {
			err = p.genDirConts(node, src, tgt)
		}

		if err != nil {
			return err
		}
	}

	return nil
}
Example #2
0
func equal(n *fs.Node, m *fs.Node) bool {
	if n.Name() != m.Name() {
		return false
	}

	if n.IsDir() != m.IsDir() {
		return false
	}

	if !n.IsDir() {
		return true
	}

	for _, nChild := range n.Children() {
		mChild, ok := m.ChildNamed(nChild.Name())

		if !ok || !equal(nChild, mChild) {
			return false
		}
	}

	return true
}