]>
Commit | Line | Data |
---|---|---|
f5d16c1c RBR |
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! | |
7ee43fb8 RBR |
30 | try? FileManager.default.createDirectory(at: self.baseDirectory.appendingPathComponent(appDirectory), |
31 | withIntermediateDirectories: true, | |
32 | attributes: nil) | |
f5d16c1c RBR |
33 | } |
34 | } |