用于cocos2d-x引擎(ndk)中為android項(xiàng)目生成編譯文件列表
package com.leeass.generate;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
/**
* 用于cocos2d-x引擎中android項(xiàng)目編譯文件列表生成
* @author leeassamite
*
*/
public class GenerateAndroidMakefile {
/** 分隔符 */
private static final String LINE_BREAK = System.getProperty("line.separator", "/n");
/** classes文件夾 */
private File classesDir = null;
/** classes文件夾路徑 */
private String classesPath = "";
/** classes文件夾相對(duì)路徑 */
private String classesRelativePath = "";
/** 編譯文件過(guò)濾器 */
private BuildFileFilter buildFileFilter = null;
/**
* 創(chuàng)建GenerateAndroidMakefile
* @param classesAbsolutePath classes文件夾絕對(duì)路徑
* @param classesRelativePath classes文件夾在編譯文件中的相對(duì)路徑
* @throws Exception
*/
public GenerateAndroidMakefile(String classesAbsolutePath,String classesRelativePath) throws Exception{
if(classesRelativePath == null){
throw new Exception("classes文件夾相對(duì)路徑錯(cuò)誤,不能為NULL!");
}
if(classesAbsolutePath == null || "".equals(classesAbsolutePath)){
throw new Exception("classes文件夾路徑輸入錯(cuò)誤,不能為空!");
}
classesDir = new File(classesAbsolutePath);
if((!classesDir.exists()) || (!classesDir.canRead()) || (!classesDir.isDirectory())){
throw new FileNotFoundException("classes文件夾不可讀:"+classesDir.getAbsolutePath());
}
this.classesPath = classesAbsolutePath;
this.classesPath = classesAbsolutePath.replaceAll("\\\\", "/");
this.classesRelativePath = classesRelativePath;
buildFileFilter = new BuildFileFilter();
}
/**
* 輸出編譯文件列表
*/
public void outputBuildFilesList(){
StringBuilder buildFilesSb = new StringBuilder();
outputBuildFileList(classesDir,buildFilesSb);
System.out.println(buildFilesSb.toString());
}
private void outputBuildFileList(File buildfile,StringBuilder buildFilesSb){
if(buildfile.isDirectory()){
File[] files =buildfile.listFiles(buildFileFilter);
for (File file : files) {
outputBuildFileList(file,buildFilesSb);
}
}else{
String buildfileStr = translateBuildFilePath(buildfile.getAbsolutePath()) + " \\";
buildFilesSb.append(buildfileStr).append(LINE_BREAK);
}
}
/**
* 轉(zhuǎn)換編譯文件路徑
* @param filepath
* @return
*/
private String translateBuildFilePath(String filepath){
return filepath.replaceAll("\\\\", "/").replace(classesPath, classesRelativePath);
}
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws Exception {
String classesPath = "D:\\developer\\cocos2d-x-2.1.4\\projects\\hszg_ol\\Classes";
String relativePath = " ../../Classes";
GenerateAndroidMakefile gam = new GenerateAndroidMakefile(classesPath,relativePath);
gam.outputBuildFilesList();
}
/**
* 編譯文件過(guò)濾器
* @author leeass
*
*/
class BuildFileFilter implements FileFilter{
@Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
return (!pathname.isHidden()) && (pathname.isDirectory() || name.endsWith(".c") || name.endsWith(".cpp"));
}
}
}
相關(guān)文章
android中關(guān)于call撥號(hào)功能的實(shí)現(xiàn)方法
這篇文章主要介紹了android中關(guān)于call撥號(hào)功能實(shí)現(xiàn)的記錄,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05
Android實(shí)現(xiàn)帶附件的郵件發(fā)送功能
這篇文章主要介紹了Android實(shí)現(xiàn)帶附件的郵件發(fā)送功能的相關(guān)資料,android發(fā)送郵件有兩種方式,本文重點(diǎn)介紹基于JMail實(shí)現(xiàn)郵件發(fā)送功能,感興趣的小伙伴們可以參考一下2016-01-01
Android中Listview下拉刷新和上拉加載更多的多種實(shí)現(xiàn)方案
本文大概通過(guò)三種方案給大家介紹了Android中Listview下拉刷新和上拉加載更多知識(shí),非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下2016-12-12
Android 實(shí)現(xiàn)夜間模式的快速簡(jiǎn)單方法實(shí)例詳解
這篇文章主要介紹了Android 實(shí)現(xiàn)夜間模式的快速簡(jiǎn)單方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09
Android仿開(kāi)心消消樂(lè)大樹(shù)星星無(wú)限循環(huán)效果
這篇文章主要為大家詳細(xì)介紹了Android仿開(kāi)心消消樂(lè)大樹(shù)星星無(wú)限循環(huán)效果,自定義view實(shí)現(xiàn)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07
Android 動(dòng)態(tài)改變SeekBar進(jìn)度條顏色與滑塊顏色的實(shí)例代碼
在上次android開(kāi)發(fā)的項(xiàng)目中遇到個(gè)這樣的需求,要?jiǎng)討B(tài)改變seekbar進(jìn)度條顏色與滑塊顏色的需求,實(shí)現(xiàn)代碼也算比較簡(jiǎn)單,對(duì)實(shí)現(xiàn)過(guò)程感興趣的朋友可以通過(guò)本文學(xué)習(xí)下2016-11-11
Android?studio實(shí)現(xiàn)動(dòng)態(tài)背景頁(yè)面
這篇文章主要為大家詳細(xì)介紹了Android?studio實(shí)現(xiàn)動(dòng)態(tài)背景頁(yè)面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
Android學(xué)習(xí)之Broadcast的簡(jiǎn)單使用
這篇文章主要為大家詳細(xì)介紹了Android學(xué)習(xí)之Broadcast的簡(jiǎn)單使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
Fiddler實(shí)現(xiàn)手機(jī)抓包之小白入門(mén)必看
這篇文章主要介紹了Fiddler實(shí)現(xiàn)手機(jī)抓包之小白入門(mén)必看篇,需要的朋友可以參考下2018-03-03

