Rename FileFactory to FileHandleFactory

This commit is contained in:
Wojciech Nagrodzki 2019-10-30 20:27:33 +01:00
parent 3f90ca9fa6
commit b49971f839
Signed by: wnagrodzki
GPG key ID: E9D0EB0302264569
3 changed files with 6 additions and 6 deletions

View file

@ -143,11 +143,11 @@ private class FileRotateFactory: LogrotateFactory {
private class FileWriterFactory: SizeLimitedFileFactory {
func makeInstance(fileURL: URL, fileSizeLimit: UInt64) throws -> SizeLimitedFile {
return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactory())
return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactoryImpl())
}
}
private class FileHandleFactory: FileFactory {
private class FileHandleFactoryImpl: FileHandleFactory {
func makeInstance(forWritingTo: URL) throws -> OSFileHandle {
return try FileHandle(forWritingTo: forWritingTo)
}

View file

@ -24,7 +24,7 @@
import Foundation
protocol FileFactory {
protocol FileHandleFactory {
func makeInstance(forWritingTo: URL) throws -> OSFileHandle
}
@ -58,7 +58,7 @@ final class SizeLimitedFileImpl {
/// - fileURL: URL of the file.
/// - fileSizeLimit: Maximum size the file can reach in bytes.
/// - Throws: An error that may occur while the file is being opened for writing.
init(fileURL: URL, fileSizeLimit: UInt64, fileFactory: FileFactory) throws {
init(fileURL: URL, fileSizeLimit: UInt64, fileFactory: FileHandleFactory) throws {
file = try fileFactory.makeInstance(forWritingTo: fileURL)
self.sizeLimit = fileSizeLimit
currentSize = file.seekToEndOfFile()

View file

@ -65,7 +65,7 @@ class SizeLimitedFileTests: XCTestCase {
}
}
private class UnopenableFileFactory: FileFactory {
private class UnopenableFileFactory: FileHandleFactory {
struct OpenFileError: Error {}
@ -74,7 +74,7 @@ private class UnopenableFileFactory: FileFactory {
}
}
private class FileMockFactory: FileFactory {
private class FileMockFactory: FileHandleFactory {
let mock = FileMock()