//
//  SIIMpaPrinterSampleApp.swift
//  SIIMpaPrinterSample
//

import SwiftUI

@main
struct SIIMpaPrinterSampleApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool{
        createSampleFile()
        return true
    }
}

func createSampleFile() {
    let filePath = NSHomeDirectory() + "/Documents/Sample.txt"
    if FileManager().fileExists(atPath: filePath)  == false{
        let result = FileManager().createFile(atPath: filePath, contents: nil, attributes: nil)
        if result {
            let text = "SampleText\n"
            do {
                try text.write(toFile: filePath, atomically: true, encoding: .utf8)
            } catch {}
        }
    }
}
