diff --git a/SwiftShell/Files.swift b/SwiftShell/Files.swift index f1e895f..d9ff4b6 100644 --- a/SwiftShell/Files.swift +++ b/SwiftShell/Files.swift @@ -43,9 +43,9 @@ separate process and changing the directory there will not affect the rest of th This directory is also used as the base for relative URL's. */ -public struct workdirectory { - public static func get() -> String { return File.currentDirectoryPath } - public static func set(newValue: String) { +public var workdirectory: String { + get { return File.currentDirectoryPath } + set { if !File.changeCurrentDirectoryPath(newValue) { printErrorAndExit("Could not change the working directory to \(newValue)") } diff --git a/SwiftShellTests/Files_Tests.swift b/SwiftShellTests/Files_Tests.swift index e893702..54f5b37 100644 --- a/SwiftShellTests/Files_Tests.swift +++ b/SwiftShellTests/Files_Tests.swift @@ -16,19 +16,19 @@ class Files_Tests: XCTestCase { } func testWorkDirectory_IsCurrentDirectory () { - XCTAssertEqual( workdirectory.get(), NSFileManager.defaultManager().currentDirectoryPath ) + XCTAssertEqual( workdirectory, NSFileManager.defaultManager().currentDirectoryPath ) } func testWorkDirectory_CanChange () { - workdirectory.set("/private/tmp") + workdirectory = "/private/tmp" - XCTAssertEqual( workdirectory.get(), "/private/tmp" ) + XCTAssertEqual( workdirectory, "/private/tmp" ) XCTAssertEqual( $("pwd"), "/private/tmp" ) } func testURLConcatenationOperator () { XCTAssertEqual( "/directory" / "file.extension", "/directory/file.extension" ) XCTAssertEqual( "/root" / "directory" / "file.extension", "/root/directory/file.extension" ) - XCTAssertEqual( "directory" / "file.extension", workdirectory.get() + "/directory/file.extension" ) + XCTAssertEqual( "directory" / "file.extension", workdirectory + "/directory/file.extension" ) } }