Skip to content

Commit 74672ec

Browse files
committed
add subscript as alias of content.
1 parent f75fcc6 commit 74672ec

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

SwiftFilePath/PathExtensionDir.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ extension Path {
3838

3939
// Add Dir Behavior to Path by extension
4040
extension Path: SequenceType {
41+
42+
public subscript(filename: String) -> Path{
43+
get { return self.content(filename) }
44+
}
4145

4246
public var children:Array<Path>? {
4347
assert(self.isDir,"To get children, path must be dir< \(path_string) >")

SwiftFilePathTests/SwiftFilePathTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class SwiftFilePathTests: XCTestCase {
7272

7373
func testDir(){
7474
let dir = sandboxDir.content("bar")
75+
let dir2 = sandboxDir["bar"]
7576
XCTAssertEqual( dir.basename, "bar")
77+
XCTAssertEqual( dir.toString(), dir2.toString() )
7678
}
7779

7880
func testFile() {

0 commit comments

Comments
 (0)