Ejemplo n.º 1
0
        public override Stream OpenRead()
        {
            var tmp = _file.OpenRead();

            _openedStream.Add(tmp);
            return(tmp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建一个<see cref="HashFilePath"/>
        /// </summary>
        /// <param name="basePath">Path to objects</param>
        /// <param name="indexPath">Path to asset index file</param>
        public HashFilePath(IFilePath basePath, IFilePath indexPath)
        {
            _basePath        = basePath;
            _currentPath     = "";
            using var stream = indexPath.OpenRead();
            using var json   = JsonDocument.Parse(stream);

            foreach (var property in json.RootElement.GetProperty("objects").EnumerateObject())
            {
                _objects.Add(property.Name, property.Value.GetProperty("hash").GetString());
            }

            _paths = _objects.Keys.ToList();

            _root = this;
        }
Ejemplo n.º 3
0
            static dynamic GetPackInfo(IFilePath packMcmeta)
            {
                var jsonDocument = JsonDocument.Parse(packMcmeta.OpenRead());
                var root         = jsonDocument.RootElement;
                var pack         = root.GetProperty("pack");
                var format       = pack.GetProperty("pack_format").GetInt32();
                var description  = pack.GetProperty("description").GetString();
                var languages    = new List <dynamic>();

                foreach (var lang in root.GetProperty("language").EnumerateObject())
                {
                    languages.Add(new
                    {
                        id            = lang.Name,
                        name          = lang.Value.GetProperty("name").GetString(),
                        region        = lang.Value.GetProperty("region").GetString(),
                        bidirectional = lang.Value.GetProperty("bidirectional").GetBoolean()
                    });
                }
                return(new { format, description, languages });
            }
Ejemplo n.º 4
0
 /// <summary>
 /// 从Zip文件创建<see cref="ZipFilePath" />
 /// </summary>
 /// <param name="zipFile"></param>
 public ZipFilePath(IFilePath zipFile) : this(zipFile.OpenRead())
 {
 }