Beispiel #1
0
        private GgpkDirectory GetRootDirectory()
        {
            RecordHeader ggpkHeader;

            do
            {
                ggpkHeader = Stream.ReadRecordHeader();
            } while (ggpkHeader.Type != RecordType.Ggpk);

            var             ggpk      = new GgpkRecord(Stream, ggpkHeader.Length);
            DirectoryRecord?dirRecord = default;

            foreach (var offset in ggpk.RecordOffsets)
            {
                Stream.Position = offset;
                RecordHeader header = Stream.ReadRecordHeader();
                if (header.Type == RecordType.Directory)
                {
                    dirRecord = new DirectoryRecord(Stream, header.Length);
                    break;
                }
            }

            return(dirRecord switch
            {
                not null => GgpkDirectory.CreateRootDirectory(dirRecord, this),
                _ => throw ParseException.GgpkParseFailure,
            });
Beispiel #2
0
        public GgpkFileSystem(string path)
        {
            _threadStream = new ThreadLocal <FileStream>(() =>
                                                         File.OpenRead(path));

            Path = path;
            Root = GetRootDirectory();
        }