mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Added size and isDirectory properties to ContainerEntry, name is no longer Optional.
This commit is contained in:
@@ -32,7 +32,9 @@ public protocol Container {
|
||||
|
||||
public protocol ContainerEntry {
|
||||
|
||||
var name: String? { get }
|
||||
var name: String { get }
|
||||
var size: Int { get }
|
||||
var isDirectory: Bool { get }
|
||||
|
||||
func data() throws -> Data
|
||||
|
||||
|
||||
@@ -25,10 +25,14 @@ public enum TarError: Error {
|
||||
public class TarEntry: ContainerEntry {
|
||||
|
||||
/// Name of the file or directory.
|
||||
public var name: String? {
|
||||
public var name: String {
|
||||
return (self.fileNamePrefix ?? "") + (self.fileName ?? "")
|
||||
}
|
||||
|
||||
public var isDirectory: Bool {
|
||||
return false // TODO: Implement.
|
||||
}
|
||||
|
||||
public let mode: Int?
|
||||
public let ownerID: Int?
|
||||
public let groupID: Int?
|
||||
|
||||
@@ -27,13 +27,11 @@ class TarTests: XCTestCase {
|
||||
return
|
||||
}
|
||||
|
||||
guard let entry = result[0] as? TarEntry else {
|
||||
XCTFail("Unable to convert to TarEntry.")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(entry.name, "test5.answer")
|
||||
XCTAssertEqual(entry.data(), Data())
|
||||
XCTAssertEqual(result.count, 1)
|
||||
XCTAssertEqual(result[0].name, "test5.answer")
|
||||
XCTAssertEqual(result[0].size, 0)
|
||||
XCTAssertEqual(result[0].isDirectory, false)
|
||||
XCTAssertEqual(try? result[0].data(), Data())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user