//
//  VideoFile.swift
//  vp
//
//  Created by soldoros on 2024/1/17.
//


import SwiftUI
import UniformTypeIdentifiers

///一个' FileDocument '的空实现，它允许SwiftUI的' fileexporters '来验证我们是否可以写入输出目的地。
struct VideoFile: FileDocument {
    static var readableContentTypes: [UTType] = [.movie, .quickTimeMovie, .mpeg4Movie]
    
    // empty data
    var data: Data
    
    init() {
        self.data = Data()
    }
    
    init(configuration: ReadConfiguration) throws {
        if let readData = configuration.file.regularFileContents {
            data = readData
        } else {
            data = Data()
        }
    }
    
    func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
        FileWrapper(regularFileWithContents: data)
    }
}

