mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Tidy up.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5059 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
06b4745d27
commit
771be28699
1 changed files with 62 additions and 60 deletions
|
@ -50,6 +50,65 @@
|
|||
|
||||
static NSSavePanel *gnustep_gui_save_panel = nil;
|
||||
|
||||
//
|
||||
// NSFileManager extensions
|
||||
//
|
||||
@interface NSFileManager (SavePanelExtensions)
|
||||
|
||||
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag;
|
||||
- (NSArray *) hiddenFilesAtPath: (NSString *)path;
|
||||
- (BOOL) fileExistsAtPath: (NSString *)path
|
||||
isDirectory: (BOOL *)flag1
|
||||
isPackage: (BOOL *)flag2;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSFileManager (SavePanelExtensions)
|
||||
|
||||
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag
|
||||
{
|
||||
NSArray *rawFiles = [self directoryContentsAtPath: path];
|
||||
NSArray *hiddenFiles = [self hiddenFilesAtPath: path];
|
||||
NSMutableArray *files = [NSMutableArray new];
|
||||
NSEnumerator *enumerator = [rawFiles objectEnumerator];
|
||||
NSString *filename;
|
||||
|
||||
if (flag || !hiddenFiles)
|
||||
return rawFiles;
|
||||
|
||||
while ((filename = (NSString *)[enumerator nextObject]))
|
||||
{
|
||||
if ([hiddenFiles indexOfObject: filename] == NSNotFound)
|
||||
[files addObject: filename];
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
- (NSArray *) hiddenFilesAtPath: (NSString *)path
|
||||
{
|
||||
NSString *hiddenList = [path stringByAppendingPathComponent: @".hidden"];
|
||||
NSString *hiddenFilesString = [NSString stringWithContentsOfFile: hiddenList];
|
||||
return [hiddenFilesString componentsSeparatedByString: @"\n"];
|
||||
}
|
||||
|
||||
- (BOOL) fileExistsAtPath: (NSString *)path
|
||||
isDirectory: (BOOL *)isDir
|
||||
isPackage: (BOOL *)isPackage
|
||||
{
|
||||
NSArray *extArray;
|
||||
|
||||
extArray = [NSArray arrayWithObjects:
|
||||
@"app", @"bundle", @"debug", @"profile", nil];
|
||||
|
||||
if ([extArray indexOfObject: [path pathExtension]] == NSNotFound)
|
||||
*isPackage = NO;
|
||||
else
|
||||
*isPackage = YES;
|
||||
return [self fileExistsAtPath: path isDirectory: isDir];
|
||||
}
|
||||
|
||||
@end /* NSFileManager (SavePanelExtensions) */
|
||||
|
||||
//
|
||||
// NSSavePanel browser delegate methods
|
||||
//
|
||||
|
@ -204,6 +263,8 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
|||
// _form = [_formControl cellAtIndex: 0];
|
||||
//}
|
||||
_prompt = [[NSTextField alloc] initWithFrame: NSMakeRect (5, 38, 38, 18)];
|
||||
[_prompt setSelectable: NO];
|
||||
[_prompt setEditable: NO];
|
||||
[_prompt setEnabled: NO];
|
||||
[_prompt setBordered: NO];
|
||||
[_prompt setBezeled: NO];
|
||||
|
@ -537,7 +598,7 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
|||
if (path == nil || filename == nil)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"NSSavePanel runModalForDirectory:file: "
|
||||
@"does not accept nil arguments."];
|
||||
@"does not accept nil arguments."];
|
||||
|
||||
// must display here so that...
|
||||
[self display];
|
||||
|
@ -640,62 +701,3 @@ static NSSavePanel *gnustep_gui_save_panel = nil;
|
|||
|
||||
@end /* NSSavePanel */
|
||||
|
||||
//
|
||||
// NSFileManager extensions
|
||||
//
|
||||
@interface NSFileManager (SavePanelExtensions)
|
||||
|
||||
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag;
|
||||
- (NSArray *) hiddenFilesAtPath: (NSString *)path;
|
||||
- (BOOL) fileExistsAtPath: (NSString *)path
|
||||
isDirectory: (BOOL *)flag1
|
||||
isPackage: (BOOL *)flag2;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSFileManager (SavePanelExtensions)
|
||||
|
||||
- (NSArray *) directoryContentsAtPath: (NSString *)path showHidden: (BOOL)flag
|
||||
{
|
||||
NSArray *rawFiles = [self directoryContentsAtPath: path];
|
||||
NSArray *hiddenFiles = [self hiddenFilesAtPath: path];
|
||||
NSMutableArray *files = [NSMutableArray new];
|
||||
NSEnumerator *enumerator = [rawFiles objectEnumerator];
|
||||
NSString *filename;
|
||||
|
||||
if (flag || !hiddenFiles)
|
||||
return rawFiles;
|
||||
|
||||
while ((filename = (NSString *)[enumerator nextObject]))
|
||||
{
|
||||
if ([hiddenFiles indexOfObject: filename] == NSNotFound)
|
||||
[files addObject: filename];
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
- (NSArray *) hiddenFilesAtPath: (NSString *)path
|
||||
{
|
||||
NSString *hiddenList = [path stringByAppendingPathComponent: @".hidden"];
|
||||
NSString *hiddenFilesString = [NSString stringWithContentsOfFile: hiddenList];
|
||||
return [hiddenFilesString componentsSeparatedByString: @"\n"];
|
||||
}
|
||||
|
||||
- (BOOL) fileExistsAtPath: (NSString *)path
|
||||
isDirectory: (BOOL *)isDir
|
||||
isPackage: (BOOL *)isPackage
|
||||
{
|
||||
NSArray *extArray;
|
||||
|
||||
extArray = [NSArray arrayWithObjects:
|
||||
@"app", @"bundle", @"debug", @"profile", nil];
|
||||
|
||||
if ([extArray indexOfObject: [path pathExtension]] == NSNotFound)
|
||||
*isPackage = NO;
|
||||
else
|
||||
*isPackage = YES;
|
||||
return [self fileExistsAtPath: path isDirectory: isDir];
|
||||
}
|
||||
|
||||
@end /* NSFileManager (SavePanelExtensions) */
|
||||
|
||||
|
|
Loading…
Reference in a new issue