public HashFilePath(HashFilePath root, string pathName) { _basePath = root._basePath; _objects = root._objects; _paths = root._paths; _root = root; _currentPath = pathName ?? throw new ArgumentNullException(nameof(pathName)); }
/// <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; }