예제 #1
0
        public void ScanBundles(string baseDir)
        {
            var dirs = new Stack <string>();

            dirs.Push(baseDir);
            while (dirs.Any())
            {
                string dir = dirs.Pop();
                foreach (var f in DirScan.DirScanner(dir))
                {
                    string filename = f.cFileName;
                    string path     = Path.Combine(dir, filename);
                    if ((f.dwFileAttributes & DirScan.FILE_ATTRIBUTE_DIRECTORY) != 0)
                    {
                        if (filename != "." && filename != "..")
                        {
                            dirs.Push(path);
                        }
                        continue;
                    }
                    if (dir.EndsWith(@"\linux") || dir.EndsWith(@"\osx"))
                    {
                        continue;
                    }
                    if (filename.Contains('.') || (f.nFileSizeHigh == 0 && f.nFileSizeLow < 1024))
                    {
                        continue;
                    }
                    CachedBundleInfo(path, f.ftLastWriteTime.ToUInt64());
                }
            }
        }
예제 #2
0
 public BundleInfo CachedBundleInfo(string path, UInt64 lastWriteTime = 0)
 {
     if (lastWriteTime == 0)
     {
         if (!DirScan.GetFileAttributesEx(path, GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, out WIN32_FILE_ATTRIBUTE_DATA fa))
         {
             throw new Exception(path + ": " + new Win32Exception().Message);
         }
         lastWriteTime = fa.ftLastWriteTime.ToUInt64();
     }
     if (!Bundles.TryGetValue(path.ToUpperInvariant(), out BundleInfo info))
     {
         Bundles.Add(path.ToUpperInvariant(), info = new BundleInfo()
         {
             path = path
         });
     }
     else if (info.lastWriteTime == lastWriteTime)
     {
         return(info);
     }
     info.lastWriteTime = lastWriteTime;
     BundleFile.ReadBundleFile(path, out List <string> materials, out List <string> gameObjects);
     info.materials = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
     foreach (var material in materials)
     {
         if (info.materials.ContainsKey(material.ToLowerInvariant()))
         {
             Logger("WARNING: Bundle " + path + " contains multiple versions of " + material);
         }
         else
         {
             info.materials.Add(material.ToLowerInvariant(), material);
         }
     }
     info.gameObjects = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
     foreach (var gameObject in gameObjects)
     {
         if (gameObject.StartsWith("entity_", StringComparison.OrdinalIgnoreCase))
         {
             info.gameObjects.Add(gameObject);
         }
     }
     return(info);
 }