示例#1
0
        public static List <string> ImportBlocksFromFolder(string path, SAV8SWSH sav)
        {
            var failed = new List <string>();
            var files  = Directory.EnumerateFiles(path);

            foreach (var f in files)
            {
                var fn = Path.GetFileNameWithoutExtension(f);

                // Trim off Value summary if present
                var space = fn.IndexOf(' ');
                if (space >= 0)
                {
                    fn = fn.Substring(0, space);
                }

                var hex = Util.GetHexValue(fn);
                try
                {
                    var block = sav.Blocks.GetBlock(hex);
                    var len   = block.Data.Length;
                    var fi    = new FileInfo(f);
                    if (fi.Length != len)
                    {
                        failed.Add(fn);
                        continue;
                    }

                    var data = File.ReadAllBytes(f);
                    data.CopyTo(block.Data, 0);
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    failed.Add(fn);
                }
            }

            return(failed);
        }