]> git.r.bdr.sh - rbdr/captura/blame_incremental - Captura/Data/CapturaFile.swift
Add about and sandbox sparkle
[rbdr/captura] / Captura / Data / CapturaFile.swift
... / ...
CommitLineData
1import Foundation
2
3struct 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 try? FileManager.default.createDirectory(at: self.baseDirectory.appendingPathComponent(appDirectory),
31 withIntermediateDirectories: true,
32 attributes: nil)
33 }
34}