Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Oct 9, 2024
1 parent f6f383d commit 7227da6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
17 changes: 13 additions & 4 deletions Sources/BushelMachine/Media/ImageFileParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@ public struct ImageFileParser: ImageInfoParser {
guard let size = cgSizeFromURL(url) else {
throw .missingField(.size)
}
let captureDestinationURL =
directoryURL
.appendingPathComponent(imageUUID.uuidString)
.appendingPathExtension(for: .init(imageType: image.configuration.fileType))

#if canImport(UniformTypeIdentifiers)
let captureDestinationURL =
directoryURL
.appendingPathComponent(imageUUID.uuidString)
.appendingPathExtension(for: .init(imageType: image.configuration.fileType))
#else
let captureDestinationURL =
directoryURL
.appendingPathComponent(imageUUID.uuidString)
.appendingPathExtension(image.configuration.fileType.fileExtension)
#endif

do {
try self.fileManager.createEmptyDirectory(
at: directoryURL,
Expand Down
11 changes: 10 additions & 1 deletion Sources/BushelMachine/Media/ImageFileType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
public enum ImageFileType: Sendable, Codable {
case jpeg
}

#if canImport(UniformTypeIdentifiers)
public import UniformTypeIdentifiers

Expand All @@ -41,5 +42,13 @@ public enum ImageFileType: Sendable, Codable {
}
}
}

#else
extension ImageFileType {
public var fileExtension: String {
switch self {
case .jpeg:
return "jpg"
}
}
}
#endif
14 changes: 8 additions & 6 deletions Sources/BushelMachineWax/Stub/MachineStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public import BushelMachine
public import Foundation

public struct MachineStub: Machine {

public var updatedConfiguration: BushelMachine.MachineConfiguration

public var machineIdentifer: UInt64? {
Expand Down Expand Up @@ -111,15 +110,18 @@ public struct MachineStub: Machine {
public func updatedMetadata(forSnapshot _: BushelMachine.Snapshot, atIndex _: Int) {
fatalError("Not implemented")
}



// swiftlint:disable:next unavailable_function
public func saveCaptureVideo(with closure: @escaping @Sendable (URL) async throws -> BushelMachine.RecordedVideo) async rethrows -> BushelMachine.RecordedVideo {
public func saveCaptureVideo(
with closure: @escaping @Sendable (URL) async throws -> BushelMachine.RecordedVideo
) async rethrows -> BushelMachine.RecordedVideo {
fatalError("Not implemented")
}

// swiftlint:disable:next unavailable_function
public func saveCaptureImage(with closure: @escaping @Sendable (URL) async throws -> BushelMachine.RecordedImage) async throws -> BushelMachine.RecordedImage {
public func saveCaptureImage(
with closure: @escaping @Sendable (URL) async throws -> BushelMachine.RecordedImage
) async throws -> BushelMachine.RecordedImage {
fatalError("Not implemented")
}
}

0 comments on commit 7227da6

Please sign in to comment.