Skip to content

Commit 3b02b0f

Browse files
committed
Remove fileExists().
1 parent 8761ac6 commit 3b02b0f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Sources/SwiftAudioFileConverter/SwiftAudioFileConverter/SwiftAudioFileConverter.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,30 @@ public actor SwiftAudioFileConverter {
66
to outputURL: URL,
77
with settings: AudioFileSettings) async throws {
88

9-
// 1. Check if the input file extension is a known audio format
9+
// Check if the input file extension is a known audio format
1010
guard FileFormat.allCases.map(\.rawValue).contains(inputURL.pathExtension.lowercased()) else {
1111
throw SwiftAudioFileConverterError.unsupportedAudioFileExtension(inputURL)
1212
}
1313

14-
// 2. If the file exists
15-
guard FileManager.default.fileExists(atPath: inputURL.path()) else {
16-
throw SwiftAudioFileConverterError.fileDoesNotExist(inputURL)
17-
}
18-
19-
// 3. Check read permissions on the input file
14+
// Check read permissions on the input file
2015
guard FileManager.default.isReadableFile(atPath: inputURL.path) else {
2116
throw SwiftAudioFileConverterError.fileIsNotReadable(inputURL)
2217
}
2318

24-
// 4. Check write permissions on the output (directory must be writable)
19+
// Check write permissions on the output (directory must be writable)
2520
// NOTE: For a brand new file, isWritableFile(atPath:) can be misleading.
2621
// Often, you'll want to check if the directory is writable instead.
2722
let outputDirectory = outputURL.deletingLastPathComponent()
2823
guard FileManager.default.isWritableFile(atPath: outputDirectory.path) else {
2924
throw SwiftAudioFileConverterError.fileIsNotWritable(outputURL)
3025
}
3126

32-
// 5. Check if output extension matches settings.fileFormat
27+
// Check if output extension matches settings.fileFormat
3328
guard outputURL.pathExtension.lowercased() == settings.fileFormat.rawValue else {
3429
throw SwiftAudioFileConverterError.audioFileExtensionSettingsMismatch(outputURL, settings)
3530
}
3631

37-
// 6. Dispatch the conversion based on the requested format
32+
// Dispatch the conversion based on the requested format
3833
switch settings.fileFormat {
3934

4035
case .wav, .aiff, .aac, .alac:

0 commit comments

Comments
 (0)