コード例 #1
0
ファイル: object.go プロジェクト: dannisliang/assetbundle-cli
// Object is TypeTree command
func Object(c *cli.Context) {
	bundles := make(map[string]*assetbundle.AssetBundle)

	var wg sync.WaitGroup
	for _, path := range c.Args() {
		wg.Add(1)
		go func(p string) {
			defer wg.Done()
			bundles[p] = assetbundle.DecodeFile(p)
		}(path)
	}
	wg.Wait()

	switch c.GlobalString("format") {
	case "json":
		j, _ := json.Marshal(bundles)
		fmt.Println(string(j))
	case "prettyjson":
		j, _ := json.MarshalIndent(bundles, "", "  ")
		fmt.Println(string(j))
	default:
		for path, bundle := range bundles {
			fmt.Println("#", path)
			for _, body := range bundle.Bodies {
				fmt.Printf("%s:\n", body.Name)
				fmt.Println("  Objects:")
				fmt.Println("    Size:", len(body.Objects.List))
				fmt.Println("    List:")
				for _, v := range body.Objects.List {
					if v.ClassID1 == v.ClassID2 {
						fmt.Printf(
							"      %d: {offset: 0x%08x, length: 0x%08x, Class: %16s}\n",
							v.ID,
							v.Offset,
							v.Length,
							v.ClassID1.String(),
						)
					} else {
						fmt.Printf(
							"      %d: {offset: 0x%08x, length: 0x%08x, ClassID1: %8d, ClassID2: %8d}\n",
							v.ID,
							v.Offset,
							v.Length,
							v.ClassID1,
							v.ClassID2,
						)
					}
				}
			}
		}
	}
}
コード例 #2
0
ファイル: crc.go プロジェクト: dannisliang/assetbundle-cli
// CRC is file info command
func CRC(c *cli.Context) {
	crcs := map[string]uint32{}
	m := new(sync.Mutex)

	var wg sync.WaitGroup
	var files []string
	if c.Bool("stdin") {
		scanner := bufio.NewScanner(os.Stdin)
		for scanner.Scan() {
			files = append(files, scanner.Text())
		}
	} else {
		files = c.Args()
	}
	for _, path := range files {
		wg.Add(1)
		go func(p string) {
			defer wg.Done()
			ab := assetbundle.DecodeFile(p)
			if len(ab.Bodies) != 1 {
				log.Fatal("Not AssetBundle")
			}
			m.Lock()
			crcs[p] = ab.Bodies[0].CRC()
			m.Unlock()
		}(path)
	}
	wg.Wait()

	switch c.GlobalString("format") {
	case "json":
		j, _ := json.Marshal(crcs)
		fmt.Println(string(j))
	case "prettyjson":
		j, _ := json.MarshalIndent(crcs, "", "  ")
		fmt.Println(string(j))
	default:
		for k, v := range crcs {
			fmt.Println(k, v)
		}
	}
}
コード例 #3
0
ファイル: ref.go プロジェクト: dannisliang/assetbundle-cli
// Ref is TypeTree command
func Ref(c *cli.Context) {
	bundles := make(map[string]*assetbundle.AssetBundle)

	var wg sync.WaitGroup
	for _, path := range c.Args() {
		wg.Add(1)
		go func(p string) {
			defer wg.Done()
			bundles[p] = assetbundle.DecodeFile(p)
		}(path)
	}
	wg.Wait()

	switch c.GlobalString("format") {
	case "json":
		j, _ := json.Marshal(bundles)
		fmt.Println(string(j))
	case "prettyjson":
		j, _ := json.MarshalIndent(bundles, "", "  ")
		fmt.Println(string(j))
	default:
		for path, bundle := range bundles {
			fmt.Println("#", path)
			for _, body := range bundle.Bodies {
				fmt.Printf("%s:\n", body.Name)
				fmt.Println("  Refs:")
				fmt.Println("    Size:", len(body.AssetRefs.List))
				fmt.Println("    List:")
				for _, v := range body.AssetRefs.List {
					fmt.Printf(
						"      %s: {type: %d, `%s` `%s`}\n",
						v.GUID.String(),
						v.Type,
						v.AssetPath,
						v.FilePath)
				}
			}
		}
	}
}
コード例 #4
0
// ObjectTree is TypeTree command
func ObjectTree(c *cli.Context) {
	bundles := make(map[string]*assetbundle.AssetBundle)

	var wg sync.WaitGroup
	for _, path := range c.Args() {
		wg.Add(1)
		go func(p string) {
			defer wg.Done()
			bundles[p] = assetbundle.DecodeFile(p)
		}(path)
	}
	wg.Wait()

	switch c.GlobalString("format") {
	case "json":
		j, _ := json.Marshal(bundles)
		fmt.Println(string(j))
	case "prettyjson":
		j, _ := json.MarshalIndent(bundles, "", "  ")
		fmt.Println(string(j))
	default:
		for path, bundle := range bundles {
			fmt.Println("#", path)
			for _, body := range bundle.Bodies {
				fmt.Printf("%s:\n", body.Name)
				fmt.Println("  Objects:")
				fmt.Println("    Size:", len(body.Objects.List))
				fmt.Println("    List:")
				for _, v := range body.Objects.List {
					if v.ClassID1 == v.ClassID2 {
						showObjectTree(body, v)
					} else {
						logrus.Fatal("ClassID1 != ClassID2")
					}
				}
			}
		}
	}
}
コード例 #5
0
// TypeTree is TypeTree command
func TypeTree(c *cli.Context) {
	bundles := make(map[string]*assetbundle.AssetBundle)

	var wg sync.WaitGroup
	for _, path := range c.Args() {
		wg.Add(1)
		go func(p string) {
			defer wg.Done()
			bundles[p] = assetbundle.DecodeFile(p)
		}(path)
	}
	wg.Wait()

	switch c.GlobalString("format") {
	case "json":
		j, _ := json.Marshal(bundles)
		fmt.Println(string(j))
	case "prettyjson":
		j, _ := json.MarshalIndent(bundles, "", "  ")
		fmt.Println(string(j))
	default:
		for path, bundle := range bundles {
			fmt.Println("#", path)
			for _, body := range bundle.Bodies {
				fmt.Printf("%s:\n", body.Name)
				fmt.Println("  TypeTree:")
				fmt.Println("    Version:", body.TypeTree.Version)
				fmt.Println("    UnityVersion:", body.TypeTree.UnityVersion)
				fmt.Println("    FieldSize:", len(body.TypeTree.Fields))
				fmt.Println("    Fields:")
				for _, f := range body.Objects.List {
					fmt.Println(format(body.TypeTree.Get(f.ClassID1), body))
				}
			}
		}
	}
}