Пример #1
0
 public void ScanAsync(string path, IScanListener listener)
 {
     new Thread(() =>
     {
         Scan(path, listener);
     }).Start();
 }
Пример #2
0
        private static void DoScan(string dir, AllResources allResources, IScanListener scanListener)
        {
            var noMmdPath = dir + System.IO.Path.DirectorySeparatorChar + ".nommdresource";

            if (File.Exists(noMmdPath))
            {
                return;
            }
            foreach (var file in Directory.GetFiles(dir))
            {
                if (scanListener != null)
                {
                    scanListener.OnScanFile(file);
                }
                var ext = System.IO.Path.GetExtension(file);
                if (!string.IsNullOrEmpty(ext))
                {
                    ext = ext.ToLower();
                }
                var fileName = System.IO.Path.GetFileName(file);
                if (".pmd".Equals(ext) || ".pmx".Equals(ext))
                {
                    allResources.ModelList.List.Add(new ResourceInfo {
                        FilePath = file, Title = fileName
                    });
                }
                else if (".vmd".Equals(ext))
                {
                    allResources.MotionList.List.Add(new ResourceInfo {
                        FilePath = file, Title = fileName
                    });
                }
                else if (".mp3".Equals(ext) || ".m4a".Equals(ext) || ".ogg".Equals(ext) || ".wav".Equals(ext))
                {
                    allResources.MusicList.List.Add(new ResourceInfo {
                        FilePath = file, Title = fileName
                    });
                }
                else if (Constants.BonePoseFileExt.Equals(ext))
                {
                    allResources.BonePoseList.List.Add(new ResourceInfo {
                        FilePath = file, Title = fileName
                    });
                }
            }
            foreach (var directory in Directory.GetDirectories(dir))
            {
                if (scanListener != null)
                {
                    scanListener.OnScanFile(directory);
                }
                DoScan(directory, allResources, scanListener);
            }
        }
Пример #3
0
        public AllResources Scan(string path, IScanListener scanListener)
        {
            var ret = new AllResources
            {
                ModelList = new ResourceList {
                    List = new List <ResourceInfo>()
                },
                MotionList = new ResourceList {
                    List = new List <ResourceInfo>()
                },
                MusicList = new ResourceList {
                    List = new List <ResourceInfo>()
                },
                BonePoseList = new ResourceList {
                    List = new List <ResourceInfo>()
                }
            };

            try
            {
                if (!new DirectoryInfo(path).Exists)
                {
                    return(ret);
                }
                DoScan(path, ret, scanListener);
                //ret.ModelList.List.Sort(ResourceComparator.Instance);
                return(ret);
            }
            finally
            {
                if (scanListener != null)
                {
                    scanListener.OnFinish(ret);
                }
            }
        }