Skip to content

Commit 6bb3d1a

Browse files
authored
Fix: extended in throughout the code (#92)
- Corrected the typo in the method name (`Extened` → `Extended`) - Updated all references to reflect the corrected spelling - Introduced a `@available(*, deprecated)` alias for the original method to maintain backward compatibility, as it was part of the public API
1 parent 27db60a commit 6bb3d1a

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Sources/ContainerizationEXT4/EXT4+Export.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ extension EXT4.EXT4Reader {
5050
var attributes: [EXT4.ExtendedAttribute] = []
5151
let buffer: [UInt8] = EXT4.tupleToArray(inode.inlineXattrs)
5252
if !buffer.allZeros {
53-
try attributes.append(contentsOf: Self.readInlineExtenedAttributes(from: buffer))
53+
try attributes.append(contentsOf: Self.readInlineExtendedAttributes(from: buffer))
5454
}
5555
if inode.xattrBlockLow != 0 {
5656
let block = inode.xattrBlockLow
5757
try self.seek(block: block)
5858
guard let buffer = try self.handle.read(upToCount: Int(self.blockSize)) else {
5959
throw EXT4.Error.couldNotReadBlock(block)
6060
}
61-
try attributes.append(contentsOf: Self.readBlockExtenedAttributes(from: [UInt8](buffer)))
61+
try attributes.append(contentsOf: Self.readBlockExtendedAttributes(from: [UInt8](buffer)))
6262
}
6363

6464
var xattrs: [String: Data] = [:]
@@ -165,15 +165,25 @@ extension EXT4.EXT4Reader {
165165
try writer.finishEncoding()
166166
}
167167

168+
@available(*, deprecated, renamed: "readInlineExtendedAttributes(from:)")
168169
public static func readInlineExtenedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
170+
try readInlineExtendedAttributes(from: buffer)
171+
}
172+
173+
public static func readInlineExtendedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
169174
let header = UInt32(littleEndian: buffer[0...4].withUnsafeBytes { $0.load(as: UInt32.self) })
170175
if header != EXT4.XAttrHeaderMagic {
171176
throw EXT4.FileXattrsState.Error.missingXAttrHeader
172177
}
173178
return try EXT4.FileXattrsState.read(buffer: buffer, start: 4, offset: 4)
174179
}
175180

181+
@available(*, deprecated, renamed: "readBlockExtendedAttributes(from:)")
176182
public static func readBlockExtenedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
183+
try readBlockExtendedAttributes(from: buffer)
184+
}
185+
186+
public static func readBlockExtendedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
177187
let header = UInt32(littleEndian: buffer[0...4].withUnsafeBytes { $0.load(as: UInt32.self) })
178188
if header != EXT4.XAttrHeaderMagic {
179189
throw EXT4.FileXattrsState.Error.missingXAttrHeader

Tests/ContainerizationEXT4Tests/TestEXT4ExtendedAttributes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ struct TestEXT4ExtendedAttribute {
7575
var blockAttrBuffer: [UInt8] = .init(repeating: 0, count: blockSize)
7676
try! state.writeInlineAttributes(buffer: &inlineAttrBuffer)
7777
try! state.writeBlockAttributes(buffer: &blockAttrBuffer)
78-
let gotInlineXattrs = try! EXT4.EXT4Reader.readInlineExtenedAttributes(from: inlineAttrBuffer)
79-
let gotBlockXattrs = try! EXT4.EXT4Reader.readBlockExtenedAttributes(from: blockAttrBuffer)
78+
let gotInlineXattrs = try! EXT4.EXT4Reader.readInlineExtendedAttributes(from: inlineAttrBuffer)
79+
let gotBlockXattrs = try! EXT4.EXT4Reader.readBlockExtendedAttributes(from: blockAttrBuffer)
8080

8181
var gotXattrs: [String: Data] = [:]
8282
for attr in gotBlockXattrs + gotInlineXattrs {

Tests/ContainerizationEXT4Tests/TestFormatterUnpack.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ extension EXT4.EXT4Reader {
165165
fileprivate func getXattrsForInode(inode: EXT4.Inode) throws -> [String: Data] {
166166
var attributes: [EXT4.ExtendedAttribute] = []
167167
let buffer: [UInt8] = EXT4.tupleToArray(inode.inlineXattrs)
168-
try attributes.append(contentsOf: Self.readInlineExtenedAttributes(from: buffer))
168+
try attributes.append(contentsOf: Self.readInlineExtendedAttributes(from: buffer))
169169
let block = inode.xattrBlockLow
170170
try self.seek(block: block)
171171
let buf = try self.handle.read(upToCount: Int(self.blockSize))!
172-
try attributes.append(contentsOf: Self.readBlockExtenedAttributes(from: [UInt8](buf)))
172+
try attributes.append(contentsOf: Self.readBlockExtendedAttributes(from: [UInt8](buf)))
173173
var xattrs: [String: Data] = [:]
174174
for attribute in attributes {
175175
guard attribute.fullName != "system.data" else {

0 commit comments

Comments
 (0)