         }
 
         // Some archives may contain source file name (this part ends with zero byte)
-        if serviceInfo.flags & Flags.fname != 0 {
+        if flags & Flags.fname != 0 {
             var fnameBytes: [UInt8] = []
             while true {
                 let byte = pointerData.alignedByte()

        - Throws: `GzipError`. It may indicate that either the data is damaged or
        it might not be compressed with gzip at all.
    */
    public init(archiveData: Data) throws {
        let serviceInfo = try GzipArchive.serviceInfo(archiveData: archiveData)
        self.compressionMethod = .deflate
        self.modificationTime = Date(timeIntervalSince1970: TimeInterval(serviceInfo.mtime))
        self.osType = FileSystemType(rawValue: serviceInfo.osType.toInt()) ?? .unknown
        self.originalFileName = serviceInfo.fileName == "" ? nil : serviceInfo.fileName
        self.comment = serviceInfo.comment == "" ? nil : serviceInfo.comment
    }

}

/// A class with unarchive function for gzip archives.
public final class GzipArchive: Archive {

    struct Flags {
        static let ftext: UInt8 = 0x01
        static let fhcrc: UInt8 = 0x02
        static let fextra: UInt8 = 0x04
        static let fname: UInt8 = 0x08
        static let fcomment: UInt8 = 0x10
    }

    struct ServiceInfo {
        let magic: Int
        let method: UInt8
        let flags: UInt8
        let mtime: Int
        let extraFlags: UInt8
        let osType: UInt8
        // Optional fields
        var fileName: String
        var comment: String
        var crc: Int
    }

    static func serviceInfo(archiveData: Data) throws -> ServiceInfo {
        let pointerData = DataWithPointer(data: archiveData, bitOrder: .reversed)
        return try serviceInfo(pointerData)
    }

    static func serviceInfo(_ pointerData: DataWithPointer) throws -> ServiceInfo {
        // First two bytes should be correct 'magic' bytes
        let magic = pointerData.intFromAlignedBytes(count: 2)
        guard magic == 0x8b1f else { throw GzipError.WrongMagic }

                fnameBytes.append(byte)
                headerBytes.append(byte)
            }
            self.originalFileName = String(data: Data(fnameBytes), encoding: .utf8)
        } else {
            self.originalFileName = nil
        }

        // Some archives may contain comment (this part also ends with zero)
        if flags & Flags.fcomment != 0 {
            var fcommentBytes: [UInt8] = []
            while true {
                let byte = pointerData.alignedByte()
