Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjohndoe committed Oct 5, 2010
0 parents commit edbe79c
Show file tree
Hide file tree
Showing 12 changed files with 5,047 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DirectoryReader.h
@@ -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
65 changes: 65 additions & 0 deletions DirectoryReader.m
@@ -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
2 changes: 2 additions & 0 deletions English.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

0 comments on commit edbe79c

Please sign in to comment.