public static void ExportLuaJson(string luaRootDir, string outputPath) {
if (System.IO.Directory.Exists(outputPath)) {
FileUtil.DeleteFileOrDirectory(outputPath);
}
Dictionary<string, string> luaList = new Dictionary<string, string>();
string[] allLuaList = System.IO.Directory.GetFiles(luaRootDir, "*", System.IO.SearchOption.AllDirectories);
for (int i = 0; i < allLuaList.Length; i++) {
string filePath = allLuaList[i];
if (filePath.EndsWith(".meta"))
continue;
if (filePath.Contains(".svn"))
continue;
if (filePath.Contains(".bak"))
continue;
if (filePath.Contains(".bat"))
continue;
if (filePath.Contains(".txt"))
continue;
if (filePath.Contains(".DS_Store"))
continue;
string luaFilePath = filePath.Replace("\\", "/").Replace(luaRootDir, "");
string luaFileMd5 = GetFileMD5(filePath);
luaList.Add(luaFilePath, luaFileMd5);
string toPath = filePath.Replace(luaRootDir, outputPath);
string toDirectory = System.IO.Path.GetDirectoryName(toPath);
if (!System.IO.Directory.Exists(toDirectory)) {
System.IO.Directory.CreateDirectory(toDirectory);
}
FileUtil.CopyFileOrDirectoryFollowSymlinks(filePath, toPath);
}
LitJson.JsonWriter writer = new LitJson.JsonWriter();
writer.PrettyPrint = true;
LitJson.JsonMapper.ToJson(luaList, writer);
System.IO.File.WriteAllText(outputPath + "luaFileList.json", writer.TextWriter.ToString());
}
请发表评论