コード例 #1
0
        public static Stream ReadCombinedAssets(this IAssetsFileProvider fp, string assetsFilePath, out bool wasCombined)
        {
            string actualName = fp.CorrectAssetFilename(assetsFilePath);

            List <string> assetFiles = new List <string>();

            if (actualName.ToLower().EndsWith("split0"))
            {
                assetFiles.AddRange(fp.FindFiles(actualName.Replace(".split0", ".split*"))
                                    .OrderBy(x => Convert.ToInt32(x.Split(new string[] { ".split" }, StringSplitOptions.None).Last())));
            }
            else
            {
                wasCombined = false;
                return(fp.GetReadStream(actualName));
            }
            wasCombined = true;
            //TODO: property or something on the file provider interface letting this code know if it should use the combined stream
            //      I think combined stream may perform horribly on zip files or cause other issues.

            if (true)
            {
                return(new CombinedStream(assetFiles, fp));
            }
            else
            {
                MemoryStream msFullFile = new MemoryStream();
                foreach (string assetsFile in assetFiles)
                {
                    byte[] fileBytes = fp.Read(assetsFile);
                    msFullFile.Write(fileBytes, 0, fileBytes.Length);
                }

                return(msFullFile);
            }
        }