@@ -16,32 +16,32 @@ public class File: Entity {
1616 return Dir ( path. stringByDeletingLastPathComponent )
1717 }
1818
19- public func touch( ) -> Either < File , String > {
19+ public func touch( ) -> Result < File , String > {
2020 return self . exists
2121 ? self . updateModificationDate ( )
2222 : self . createEmptyFile ( )
2323 }
2424
25- public func updateModificationDate( date: NSDate = NSDate ( ) ) -> Either < File , String > {
25+ public func updateModificationDate( date: NSDate = NSDate ( ) ) -> Result < File , String > {
2626 var error : NSError ?
2727 let result = fileManager. setAttributes (
2828 [ NSFileModificationDate : date] ,
2929 ofItemAtPath: path,
3030 error: & error
3131 )
3232 return result
33- ? Either ( success: self )
34- : Either ( failure: " Failed to modify file.< error: \( error? . localizedDescription) path: \( path) > " ) ;
33+ ? Result ( success: self )
34+ : Result ( failure: " Failed to modify file.< error: \( error? . localizedDescription) path: \( path) > " ) ;
3535 }
3636
37- private func createEmptyFile( ) -> Either < File , String > {
37+ private func createEmptyFile( ) -> Result < File , String > {
3838 let result = fileManager. createFileAtPath ( path,
3939 contents: NSData ( ) ,
4040 attributes: nil
4141 )
4242 return result
43- ? Either ( success: self )
44- : Either ( failure: " Failed to create file: \( path) " ) ;
43+ ? Result ( success: self )
44+ : Result ( failure: " Failed to create file: \( path) " ) ;
4545 }
4646
4747 // MARK: - read/write String
@@ -59,15 +59,15 @@ public class File: Entity {
5959 return read
6060 }
6161
62- public func writeString( string: String ) -> Either < File , String > {
62+ public func writeString( string: String ) -> Result < File , String > {
6363 var error : NSError ?
6464 let result = string. writeToFile ( path,
6565 atomically: true ,
6666 encoding: NSUTF8StringEncoding,
6767 error: & error)
6868 return result
69- ? Either ( success: self )
70- : Either ( failure: " Failed to write file.< error: \( error? . localizedDescription) path: \( path) > " ) ;
69+ ? Result ( success: self )
70+ : Result ( failure: " Failed to write file.< error: \( error? . localizedDescription) path: \( path) > " ) ;
7171 }
7272
7373 // MARK: - read/write NSData
@@ -76,11 +76,11 @@ public class File: Entity {
7676 return NSData ( contentsOfFile: path)
7777 }
7878
79- public func writeData( data: NSData ) -> Either < File , String > {
79+ public func writeData( data: NSData ) -> Result < File , String > {
8080 let result = data. writeToFile ( path, atomically: true )
8181 return result
82- ? Either ( success: self )
83- : Either ( failure: " Failed to write file.< path: \( path) > " ) ;
82+ ? Result ( success: self )
83+ : Result ( failure: " Failed to write file.< path: \( path) > " ) ;
8484 }
8585
8686}
0 commit comments