public static ArchiveFile Create(string path) { switch (Game.Instance.ImgVersion) { case ArchiveFileVersion.V1: return ArchiveFileV1.Create(path); case ArchiveFileVersion.V2: return ArchiveFileV2.Create(path); default: throw new InvalidOperationException(); } }
/// <summary> /// Creates new handle instance to use archive from filesystem based on the archive version /// </summary> /// <summary xml:lang="ru"> /// Создание нового указателя на архив, расположенный в файле на основании его версии /// </summary> /// <param name="path">Archive file path</param> /// <param name="path" xml:lang="ru">Путь к архиву</param> /// <returns> /// New <see cref="ArchiveFile"/> instance /// </returns> /// <returns xml:lang="ru"> /// Новый инстанс <see cref="ArchiveFile"/> /// </returns> public static new ArchiveFile CreateInstance(string path) { ArchiveFileVersion version = ArchiveFileV2.ReadVersionFromArchive(new GameFile(path)); // We've tried to extract the version from the archive file itself in readVersionFromImg(). // If we've failed, then we're checking if we have a .dir file nearby. // That indicates that we deal with V1 archive. if (version == ArchiveFileVersion.Unknown) { version = File.Exists(ArchiveFileV1.GetDirFilePath(path)) ? ArchiveFileVersion.V1 : ArchiveFileVersion.Unknown; } switch (version) { case ArchiveFileVersion.V1: return new ArchiveFileV1(path); case ArchiveFileVersion.V2: return new ArchiveFileV2(path); default: throw new Exception("Invalid archive version"); } }