Commits

Jens Alfke  committed 2cb1893

Importing patch from oscherler, for opening binary files (re #33)

  • Participants
  • Parent commits ae3caf4

Comments (0)

Files changed (6)

File Source/HgFile.h

 
 - (void) addFilesMatching: (Predicate)predicate toArray: (NSMutableArray*)array;
 
-@property (readonly,nonatomic) NSString* contents;
+@property (readonly,nonatomic) NSData* contents;
 
 @property (readonly,nonatomic) NSArray* revisions;    // array of HgRevision
 

File Source/HgFile.m

 }
 
 
-- (NSString*) contents
+- (NSData*) contents
 {
-    return [NSString stringWithContentsOfFile: self.absolutePath
-                                 usedEncoding: NULL
-                                        error: nil];
+    return [NSData dataWithContentsOfFile: self.absolutePath];
 }
 
 

File Source/HgRevision.h

 
 - (HgFile*) fileAtPath: (NSString*)path;
 
-- (NSString*) getFileContents: (HgFile*)file error: (NSError**)outError;
+- (NSData*) getFileContents: (HgFile*)file error: (NSError**)outError;
 - (NSString*) getPathToFileContents: (HgFile*)file inTempDir: (HgTempDir*)tempDir error: (NSError**)outError;
 - (NSString*) diffFile: (HgFile*)file withRevisionNumber: (int)otherRev error: (NSError**)outError;
 - (NSString*) diffFile: (HgFile*)file withRevision: (HgRevision*)other error: (NSError**)outError;

File Source/HgRevision.m

 #pragma mark FILE CONTENTS / COMPARISONS:
 
 
-- (NSString*) getFileContents: (HgFile*)file error: (NSError**)outError
+- (NSData*) getFileContents: (HgFile*)file error: (NSError**)outError
 {
     HgOperation *op = [[HgOperation alloc] initWithDirectory: file.root
                                                      command: @"cat",
         *outError = op.error;
         return nil;
     }
-    return op.output;
+    return op.outputData;
 }
 
 
 - (NSString*) getPathToFileContents: (HgFile*)file inTempDir: (HgTempDir*)tempDir error: (NSError**)outError
 {
     Assert(tempDir);
-    NSString *contents = [self getFileContents: file error: outError];
+    NSData *contents = [self getFileContents: file error: outError];
     if( ! contents )
         return nil;
     return [tempDir writeData: contents 

File Source/HgUncommittedRevision.m

 - (NSString*) formattedDescription                  {return _comment;}
 - (void) setFormattedDescription: (NSString*)str    {self.comment = str;}
 
-- (NSString*) getFileContents: (HgFile*)file error: (NSError**)outError
+- (NSData*) getFileContents: (HgFile*)file error: (NSError**)outError
 {
     *outError = nil;
     return file.contents;

File Source/RepoController_Actions.m

                 return;
         } else {
             NSError *error = nil;
-            NSString *contents = [rev getFileContents: file error: &error];
+            NSData *contents = [rev getFileContents: file error: &error];
             if( contents ) {
                 NSString *filename = [NSString stringWithFormat: @"(r%i) %@", rev.localNumber,file.name];
                 if( [self.tempDir openDataInEditor: contents