Ejemplo n.º 1
0
    static void CopyLuaBytesFiles(string sourceDir, string destDir, bool appendext = true, string searchPattern = "*.lua", SearchOption option = SearchOption.AllDirectories)
    {
        if (!Directory.Exists(sourceDir))
        {
            return;
        }

        string[] files = Directory.GetFiles(sourceDir, searchPattern, option);
        int      len   = sourceDir.Length;

        if (sourceDir[len - 1] == '/' || sourceDir[len - 1] == '\\')
        {
            --len;
        }
        XLua.LuaEnv L = new XLua.LuaEnv();
        for (int i = 0; i < files.Length; i++)
        {
            string str  = files[i].Remove(0, len);
            string dest = destDir + "/" + str;
            if (appendext && !dest.EndsWith(".bytes"))
            {
                dest += ".bytes";
            }
            string dir = Path.GetDirectoryName(dest);
            Directory.CreateDirectory(dir);
            CompileLuaFile(L, files[i], dest);
            //File.Copy(files[i], dest, true);
        }

        L.LuacClear();
        L.GC();
        L.Dispose();
    }