-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneMetadata.swift
42 lines (37 loc) · 1.36 KB
/
SceneMetadata.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Metadata.swift
// MobileLighting_iPhone
//
// Created by Nicholas Mosier on 5/30/18.
// Copyright © 2018 Nicholas Mosier. All rights reserved.
//
import Foundation
class SceneMetadata {
var focus: Float!
var exposureDurations: [Double]!
//var exposureISOs: [Double]!
var angle: Double!
func getMetadataYAMLData() -> NSData {
var out: String = String()
out += "focus: " + String(self.focus) + "\n" // focus
out += "exposureDurations:\n"
for exposureDuration in self.exposureDurations {
out += " - " + String(exposureDuration) + "\n"
}
out += "angle: " + String(angle)
guard let data: NSData = out.data(using: .utf8) as NSData? else {
fatalError("SceneMetadata error: cannot get data from string")
}
return data
}
func saveMetadataData(_ data: NSData, toFile filepath: String) {
let dir: String = filepath.split(separator: "/").dropLast().joined(separator: "/")
do {
try FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true, attributes: nil)
//try data.write(to: filepath, atomically: true)
data.write(toFile: filepath, atomically: true)
} catch let file_error as NSError {
print(file_error.localizedDescription)
}
}
}