• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tests.utils;
18 
19 import com.badlogic.gdx.files.FileHandle;
20 
21 /** Used to generate an assets.txt file for a specific directory.
22  * @author mzechner */
23 public class AssetsFileGenerator {
main(String[] args)24 	public static void main (String[] args) {
25 		FileHandle file = new FileHandle(args[0]);
26 		StringBuffer list = new StringBuffer();
27 		args[0] = args[0].replace("\\", "/");
28 		if (!args[0].endsWith("/")) args[0] = args[0] + "/";
29 		traverse(file, args[0], list);
30 		new FileHandle(args[0] + "/assets.txt").writeString(list.toString(), false);
31 	}
32 
traverse(FileHandle directory, String base, StringBuffer list)33 	private static final void traverse (FileHandle directory, String base, StringBuffer list) {
34 		if (directory.name().equals(".svn")) return;
35 		String dirName = directory.toString().replace("\\", "/").replace(base, "") + "/";
36 		System.out.println(dirName);
37 		for (FileHandle file : directory.list()) {
38 			if (file.isDirectory()) {
39 				traverse(file, base, list);
40 			} else {
41 				String fileName = file.toString().replace("\\", "/").replace(base, "");
42 				if (fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
43 					list.append("i:" + fileName + "\n");
44 					System.out.println(fileName);
45 				} else if (fileName.endsWith(".glsl") || fileName.endsWith(".fnt") || fileName.endsWith(".pack")
46 					|| fileName.endsWith(".obj") || file.extension().equals("") || fileName.endsWith("txt")) {
47 					list.append("t:" + fileName + "\n");
48 					System.out.println(fileName);
49 				} else {
50 					if (fileName.endsWith(".mp3") || fileName.endsWith(".ogg") || fileName.endsWith(".wav")) continue;
51 					list.append("b:" + fileName + "\n");
52 					System.out.println(fileName);
53 				}
54 			}
55 		}
56 	}
57 }
58