-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit edbe79c
Showing
12 changed files
with
5,047 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// DirectoryReader.h | ||
// LineReader | ||
// | ||
// Created by Tobias Preuss on 05.10.10. | ||
// Copyright 2010 Tobias Preuss. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface DirectoryReader : NSObject { | ||
|
||
NSString* m_path; | ||
} | ||
|
||
- (BOOL)readDirectory:(NSArray**)files; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// DirectoryReader.m | ||
// LineReader | ||
// | ||
// Created by Tobias Preuss on 05.10.10. | ||
// Copyright 2010 Tobias Preuss. All rights reserved. | ||
// | ||
|
||
#import "DirectoryReader.h" | ||
|
||
|
||
/** | ||
A directory reader. | ||
*/ | ||
@implementation DirectoryReader | ||
|
||
|
||
/** | ||
Initializes a directory reader. | ||
@param path A directory path. | ||
@returns An initialized DirectoryReader object or nil if the object could not be created. | ||
*/ | ||
- (id)initWithPath:(NSString*)path { | ||
|
||
self = [super init]; | ||
if (self != nil) { | ||
m_path = path; | ||
} | ||
return self; | ||
} | ||
|
||
/** | ||
Reads the content of a directory. | ||
@param files Container for the listing. | ||
@returns YES if the directory was read otherwise NO. | ||
*/ | ||
- (BOOL)readDirectory:(NSArray**)files { | ||
|
||
|
||
BOOL success = false; | ||
if (!m_path) { | ||
return success; | ||
} | ||
|
||
NSArray* fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:m_path error:nil]; | ||
|
||
if (!fileNames || [fileNames count] <= 0) { | ||
return success; | ||
} | ||
|
||
NSMutableArray* fullNames = [NSMutableArray arrayWithCapacity:[fileNames count]]; | ||
for (NSString* fileName in fileNames) { | ||
NSString* fullPath = [m_path stringByAppendingString:[NSString stringWithFormat:@"/%@", fileName]]; | ||
[fullNames addObject:fullPath]; | ||
} | ||
|
||
if (fullNames && [fullNames count] > 0 && files) { | ||
*files = fullNames; | ||
success = YES; | ||
} | ||
return success; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
Oops, something went wrong.