func prepareSingleSegment()

in Sources/TSFCASFileTree/FileTreeImport.swift [817:840]


    func prepareSingleSegment(of file: FileSegmenter, segmentNumber: Int, useCompression: Bool) throws -> LLBFastData {

        let rawData: LLBFastData
        // Any error from fetchSegment in this function is a .modifiedFile
        // error: we did read this file before and it was ok!
        // We throw this error even under relaxConsistencyChecks, and
        // check it in location /EC1.
        do {
            guard let (data, _) = try file.fetchSegment(segmentNumber: segmentNumber) else {
                throw ImportError.modifiedFile(file.path, reason: "Can't reopen")
            }
            rawData = data
        } catch FileSegmenter.Error.resourceChanged(let reason) {
            throw ImportError.modifiedFile(file.path, reason: reason)
        } catch {
            throw ImportError.modifiedFile(file.path, reason: "\(error)")
        }

        guard useCompression else {
            return rawData
        }

        return try rawData.compressed(allocator: options.compressBufferAllocator!)
    }