]> git.r.bdr.sh - rbdr/captura/blob - Captura/Data/CapturaFile.swift
da1f2fb3fced4baa86a65eea36b8bc5951c1e527
[rbdr/captura] / Captura / Data / CapturaFile.swift
1 import Foundation
2
3 struct CapturaFile {
4
5 let name: String
6 let baseDirectory: URL
7 let appDirectory: String = "captura"
8
9 private var baseURL: URL {
10 baseDirectory.appendingPathComponent("\(appDirectory)/\(name)")
11 }
12
13 var mp4URL: URL {
14 return baseURL.appendingPathExtension("mp4")
15 }
16
17 var gifURL: URL {
18 return baseURL.appendingPathExtension("gif")
19 }
20
21 init() {
22 let dateFormatter = DateFormatter()
23 dateFormatter.dateStyle = .medium
24 dateFormatter.timeStyle = .medium
25 dateFormatter.locale = Locale.current
26 let dateString = dateFormatter.string(from: Date()).replacingOccurrences(of: ":", with: ".")
27
28 self.name = "Captura \(dateString)"
29 self.baseDirectory = FileManager.default.urls(for: .picturesDirectory, in: .userDomainMask).first!
30 }
31 }