MijickCamera/Sources/Internal/Extensions/FileManager++.swift

36 lines
987 B
Swift
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// FileManager++.swift of MijickCamera
//
// Created by Tomasz Kurylik. Sending from Kraków!
// - Mail: tomasz.kurylik@mijick.com
// - GitHub: https://github.com/FulcrumOne
// - Medium: https://medium.com/@mijick
//
// Copyright ©2024 Mijick. All rights reserved.
import SwiftUI
// MARK: Prepare Place for Video Output
extension FileManager {
static func prepareURLForVideoOutput() -> URL? {
guard let fileUrl = getFileUrl() else { return nil }
clearPlaceIfTaken(fileUrl)
return fileUrl
}
}
private extension FileManager {
static func getFileUrl() -> URL? {
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
.first?
.appendingPathComponent(videoPath)
}
static func clearPlaceIfTaken(_ url: URL) {
try? FileManager.default.removeItem(at: url)
}
}
private extension FileManager {
static var videoPath: String { "mijick-camera-video-output.mp4" }
}