@@ -25,14 +25,15 @@ func parseBasePath (file: NSFileHandle) -> String {
2525}
2626
2727func updateBasePath ( file: NSFileHandle , newPath: String ) -> Int {
28- if count ( newPath) > 256 {
29- println ( " Path too long " )
28+ if newPath. characters. count > 256
29+ {
30+ print ( " Path too long " )
3031 return 1
3132 }
3233 // Write length byte
3334 let lengthByteOffset : UInt64 = 0x13
3435 file. seekToFileOffset ( lengthByteOffset)
35- let lengthByte = NSData ( bytes: [ UInt8 ( count ( newPath) ) ] , length: 1 )
36+ let lengthByte = NSData ( bytes: [ UInt8 ( newPath. characters . count ) ] , length: 1 )
3637 file. writeData ( lengthByte)
3738
3839 // Write path
@@ -48,9 +49,9 @@ func updateBasePath (file: NSFileHandle, newPath: String) -> Int {
4849// Entry point
4950
5051if Process . arguments. count < 3 {
51- println ( " Usage: \( Process . arguments [ 0 ] ) [patch|revert] qcow_path [orig_path] " )
52- println ( " 1) ' \( Process . arguments [ 0 ] ) patch qcow_path' outputs original path to backing image " )
53- println ( " 2) ' \( Process . arguments [ 0 ] ) revert qcow_path orig_path' sets path to backing image back to orig_path " )
52+ print ( " Usage: \( Process . arguments [ 0 ] ) [patch|revert] qcow_path [orig_path] " )
53+ print ( " 1) ' \( Process . arguments [ 0 ] ) patch qcow_path' outputs original path to backing image " )
54+ print ( " 2) ' \( Process . arguments [ 0 ] ) revert qcow_path orig_path' sets path to backing image back to orig_path " )
5455 exit ( 1 )
5556}
5657
@@ -62,11 +63,11 @@ if let modeStr = String.fromCString(Process.arguments[1]) {
6263 } else if modeStr == " revert " {
6364 mode = Mode . Revert
6465 } else {
65- println ( " Invalid mode " )
66+ print ( " Invalid mode " )
6667 exit ( 1 )
6768 }
6869} else {
69- println ( " Invalid mode " )
70+ print ( " Invalid mode " )
7071 exit ( 1 )
7172}
7273
@@ -78,28 +79,28 @@ func main () -> Int32 {
7879 // }
7980 let error : Int
8081 if mode == Mode . Patch {
81- println ( parseBasePath ( file) )
82- error = updateBasePath ( file, " C: \\ ece391 \\ devel \\ ece391.qcow " )
82+ print ( parseBasePath ( file) )
83+ error = updateBasePath ( file, newPath : " C: \\ ece391 \\ devel \\ ece391.qcow " )
8384 } else {
8485 if let newPath = Process . arguments. count >= 4 ? String . fromCString ( Process . arguments [ 3 ] ) : nil {
85- error = updateBasePath ( file, newPath)
86+ error = updateBasePath ( file, newPath: newPath )
8687 } else {
87- println ( " Please specify new backing image path " )
88+ print ( " Please specify new backing image path " )
8889 file. closeFile ( )
8990 return 1
9091 }
9192 }
9293 if error != 0 {
93- println ( " Error occurred " )
94+ print ( " Error occurred " )
9495 file. closeFile ( )
9596 return 1
9697 }
9798 } else {
98- println ( " Cannot open file " )
99+ print ( " Cannot open file " )
99100 return 1
100101 }
101102 } else {
102- println ( " Invalid path " )
103+ print ( " Invalid path " )
103104 return 1
104105 }
105106 return 0
0 commit comments