Files
gitx/PBGitTree.h
T
Johannes Gilger 8243cf58b3 PBGitTree: Don't try to print binary-file contents
This patch prevents the plaintext display of files with binary content
in tree-view by connecting the content to the textContents attribute.

PBGitTree is extended with the method textContents, which returns the
textual representation of a PBGitTree-object. The methods first checks
the output of "git check-attr binary <file>" to see if the user
set/unset the binary attribute manually. Then it checks for common
binary file-extensions. If this method can't determine whether the file
is binary, the file-content is loaded and Unix "file" is run on the
first 100 bytes of the file to make a decision.

It also adds the -[PBGitTree fileSize] method to check the size
of the file before actually loading its contents.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
Edited-by: Pieter de Bie <pdebie@ai.rug.nl>
2009-09-07 14:38:44 +02:00

44 lines
957 B
Objective-C

//
// PBGitTree.h
// GitTest
//
// Created by Pieter de Bie on 15-06-08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PBGitRepository.h"
@interface PBGitTree : NSObject {
long long _fileSize;
NSString* sha;
NSString* path;
PBGitRepository* repository;
__weak PBGitTree* parent;
NSArray* children;
BOOL leaf;
NSString* localFileName;
NSDate* localMtime;
}
+ (PBGitTree*) rootForCommit: (id) commit;
+ (PBGitTree*) treeForTree: (PBGitTree*) tree andPath: (NSString*) path;
- (void) saveToFolder: (NSString *) directory;
- (NSString*) tmpFileNameForContents;
- (long long)fileSize;
@property(copy) NSString* sha;
@property(copy) NSString* path;
@property(assign) BOOL leaf;
@property(retain) PBGitRepository* repository;
@property(assign) __weak PBGitTree* parent;
@property(readonly) NSArray* children;
@property(readonly) NSString* fullPath;
@property(readonly) NSString* contents;
@end