Beispiel #1
0
        public static IEnumerable <string> GetContent(string filePath)
        {
            using (FileStream fs = File.OpenRead(filePath))
                using (var gzs = new GZipStream(fs, CompressionMode.Decompress))
                {
                    var reader = new RawDataReader(gzs, Encoding.UTF8);

                    foreach (byte b in Signature)
                    {
                        if (b != reader.ReadByte())
                        {
                            throw new CorruptedFileException(filePath);
                        }
                    }

                    int nbDir   = reader.ReadInt();
                    var folders = new List <string>(nbDir);

                    for (int i = 0; i < nbDir; ++i)
                    {
                        string dir = reader.ReadString();
                        folders.Add(dir);
                    }


                    int nbFile = reader.ReadInt();
                    var files  = new List <string>(nbFile);

                    for (int i = 0; i < nbFile; ++i)
                    {
                        string file   = reader.ReadString();
                        int    ndxDir = reader.ReadInt();

                        if (ndxDir != NDX_CUR_FOLDER)
                        {
                            file = Path.Combine(folders[ndxDir], file);
                        }

                        files.Add(file);
                        long fileLen = reader.ReadLong();
                        reader.Skip((int)fileLen);
                    }

                    return(files);
                }
        }