Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial import.

  • Loading branch information...
commit edbe79c4669b94c030ce1ad97aa9f224870f3fce 0 parents
@johnjohndoe authored
19 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 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  English.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
4,315 English.lproj/MainMenu.xib
4,315 additions, 0 deletions not shown
35 FileReader.h
@@ -0,0 +1,35 @@
+//
+// FileReader.h
+// LineReader
+//
+// Created by Tobias Preuss on 05.10.10.
+// Copyright 2010 Tobias Preuss. All rights reserved.
+//
+// Source: Dave DeLong, http://stackoverflow.com/questions/3707427#3711079
+
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface FileReader : NSObject {
+
+ NSString* m_filePath;
+ NSFileHandle* m_fileHandle;
+ unsigned long long m_currentOffset;
+ unsigned long long m_totalFileLength;
+ NSString* m_lineDelimiter;
+ NSUInteger m_chunkSize;
+}
+
+@property (nonatomic, copy) NSString* lineDelimiter;
+@property (nonatomic) NSUInteger chunkSize;
+
+- (id)initWithFilePath:(NSString*)filePath;
+- (NSString*)readLine;
+- (NSString*)readTrimmedLine;
+
+#if NS_BLOCKS_AVAILABLE
+- (void)enumerateLinesUsingBlock:(void(^)(NSString*, BOOL*))block;
+#endif
+
+@end
179 FileReader.m
@@ -0,0 +1,179 @@
+//
+// FileReader.m
+// LineReader
+//
+// Created by Tobias Preuss on 05.10.10.
+// Copyright 2010 Tobias Preuss. All rights reserved.
+//
+// Source: Dave DeLong, http://stackoverflow.com/questions/3707427#3711079
+
+
+#import "FileReader.h"
+
+
+
+// -----------------------------------------------------------------------------
+// NSData extension.
+// -----------------------------------------------------------------------------
+
+
+@interface NSData (Additions)
+
+- (NSRange)rangeOfData:(NSData*)dataToFind;
+
+@end
+
+
+
+/**
+ Extension of the NSData class.
+ @param Additions Additions.
+ @returns An initialized NSData object or nil if the object could not be created.
+ */
+@implementation NSData (Additions)
+
+
+/**
+ Returns a range of data.
+ @param dataToFind Data object specifying the delimiter and encoding.
+ @returns A range.
+ */
+- (NSRange)rangeOfData:(NSData*)dataToFind {
+
+
+ const void* bytes = [self bytes];
+ NSUInteger length = [self length];
+ const void* searchBytes = [dataToFind bytes];
+ NSUInteger searchLength = [dataToFind length];
+ NSUInteger searchIndex = 0;
+
+ NSRange foundRange = {NSNotFound, searchLength};
+ for (NSUInteger index = 0; index < length; index++) {
+ if (((char*)bytes)[index] == ((char*)searchBytes)[searchIndex]) {
+ // The current character matches.
+ if (foundRange.location == NSNotFound) {
+ foundRange.location = index;
+ }
+ searchIndex++;
+ if (searchIndex >= searchLength) {
+ return foundRange;
+ }
+ }
+ else {
+ searchIndex = 0;
+ foundRange.location = NSNotFound;
+ }
+ }
+ return foundRange;
+}
+
+@end
+
+
+
+
+// -----------------------------------------------------------------------------
+// FileReader class.
+// -----------------------------------------------------------------------------
+
+
+
+
+/**
+ A file reader.
+ */
+@implementation FileReader
+
+
+@synthesize lineDelimiter = m_lineDelimiter;
+@synthesize chunkSize = m_chunkSize;
+
+
+/**
+ Initialized a file reader object.
+ @param filePath A file path.
+ @returns An initialized FileReader object or nil if the object could not be created.
+ */
+- (id)initWithFilePath:(NSString*)filePath {
+
+
+ self = [super init];
+ if (self != nil) {
+ m_fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];
+ if (m_fileHandle == nil) {
+ return nil;
+ }
+ m_lineDelimiter = [[NSString alloc] initWithString:@"\n"];
+ m_filePath = filePath;
+ m_currentOffset = 0ULL;
+ m_chunkSize = 10;
+ [m_fileHandle seekToEndOfFile];
+ m_totalFileLength = [m_fileHandle offsetInFile];
+ // We do not need to seek back since readLine will do that.
+ }
+ return self;
+}
+
+/**
+ Reads the file forwards.
+ @returns Another single line on each call or nil if the file end has been reached.
+ */
+- (NSString*)readLine {
+
+
+ if (m_currentOffset >= m_totalFileLength) {
+ return nil;
+ }
+
+ NSData* newLineData = [m_lineDelimiter dataUsingEncoding:NSUTF8StringEncoding];
+ [m_fileHandle seekToFileOffset:m_currentOffset];
+ NSMutableData* currentData = [[NSMutableData alloc] init];
+ BOOL shouldReadMore = YES;
+
+ while (shouldReadMore) {
+ if (m_currentOffset >= m_totalFileLength) {
+ break;
+ }
+ NSData* chunk = [m_fileHandle readDataOfLength:m_chunkSize];
+ NSRange newLineRange = [chunk rangeOfData:newLineData];
+ if (newLineRange.location != NSNotFound) {
+ // Include the length so we can include the delimiter in the string.
+ chunk = [chunk subdataWithRange:NSMakeRange(0, newLineRange.location + [newLineData length])];
+ shouldReadMore = NO;
+ }
+ [currentData appendData:chunk];
+ m_currentOffset += [chunk length];
+ }
+
+ NSString* line = [[NSString alloc] initWithData:currentData encoding:NSUTF8StringEncoding];
+ return line;
+}
+
+/**
+ Reads the file forwards while trimming white spaces.
+ @returns Another single line on each call or nil if the file end has been reached.
+ */
+- (NSString*)readTrimmedLine {
+
+
+ return [[self readLine] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+}
+
+
+#if NS_BLOCKS_AVAILABLE
+/**
+ Reads the file forwards using a block object.
+ @param block
+ */
+- (void)enumerateLinesUsingBlock:(void(^)(NSString*, BOOL*))block {
+ NSString* line = nil;
+ BOOL stop = NO;
+ while (stop == NO && (line = [self readLine])) {
+ block(line, &stop);
+ }
+}
+#endif
+
+
+
+@end
32 LineReader-Info.plist
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
297 LineReader.xcodeproj/project.pbxproj
@@ -0,0 +1,297 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
+ 256AC3DA0F4B6AC300CF3369 /* LineReaderAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* LineReaderAppDelegate.m */; };
+ 5548D857125B69B6001C6932 /* FileReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 5548D856125B69B6001C6932 /* FileReader.m */; };
+ 558DC637125B369600AF819E /* DirectoryReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 558DC636125B369600AF819E /* DirectoryReader.m */; };
+ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
+ 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
+ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
+ 1DDD58150DA1D0A300B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ 256AC3D80F4B6AC300CF3369 /* LineReaderAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineReaderAppDelegate.h; sourceTree = "<group>"; };
+ 256AC3D90F4B6AC300CF3369 /* LineReaderAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LineReaderAppDelegate.m; sourceTree = "<group>"; };
+ 256AC3F00F4B6AF500CF3369 /* LineReader_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineReader_Prefix.pch; sourceTree = "<group>"; };
+ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
+ 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 5548D855125B69B6001C6932 /* FileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileReader.h; sourceTree = "<group>"; };
+ 5548D856125B69B6001C6932 /* FileReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileReader.m; sourceTree = "<group>"; };
+ 558DC635125B369600AF819E /* DirectoryReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryReader.h; sourceTree = "<group>"; };
+ 558DC636125B369600AF819E /* DirectoryReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryReader.m; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* LineReader-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "LineReader-Info.plist"; sourceTree = "<group>"; };
+ 8D1107320486CEB800E47090 /* LineReader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LineReader.app; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8D11072E0486CEB800E47090 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 080E96DDFE201D6D7F000001 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ 256AC3D80F4B6AC300CF3369 /* LineReaderAppDelegate.h */,
+ 256AC3D90F4B6AC300CF3369 /* LineReaderAppDelegate.m */,
+ 558DC635125B369600AF819E /* DirectoryReader.h */,
+ 558DC636125B369600AF819E /* DirectoryReader.m */,
+ 5548D855125B69B6001C6932 /* FileReader.h */,
+ 5548D856125B69B6001C6932 /* FileReader.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
+ );
+ name = "Linked Frameworks";
+ sourceTree = "<group>";
+ };
+ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 29B97324FDCFA39411CA2CEA /* AppKit.framework */,
+ 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
+ 29B97325FDCFA39411CA2CEA /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ 19C28FACFE9D520D11CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8D1107320486CEB800E47090 /* LineReader.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 29B97314FDCFA39411CA2CEA /* SequentialReader */ = {
+ isa = PBXGroup;
+ children = (
+ 080E96DDFE201D6D7F000001 /* Classes */,
+ 29B97315FDCFA39411CA2CEA /* Other Sources */,
+ 29B97317FDCFA39411CA2CEA /* Resources */,
+ 29B97323FDCFA39411CA2CEA /* Frameworks */,
+ 19C28FACFE9D520D11CA2CBB /* Products */,
+ );
+ name = SequentialReader;
+ sourceTree = "<group>";
+ };
+ 29B97315FDCFA39411CA2CEA /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 256AC3F00F4B6AF500CF3369 /* LineReader_Prefix.pch */,
+ 29B97316FDCFA39411CA2CEA /* main.m */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+ 29B97317FDCFA39411CA2CEA /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 8D1107310486CEB800E47090 /* LineReader-Info.plist */,
+ 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
+ 1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
+ 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8D1107260486CEB800E47090 /* LineReader */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "LineReader" */;
+ buildPhases = (
+ 8D1107290486CEB800E47090 /* Resources */,
+ 8D11072C0486CEB800E47090 /* Sources */,
+ 8D11072E0486CEB800E47090 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = LineReader;
+ productInstallPath = "$(HOME)/Applications";
+ productName = SequentialReader;
+ productReference = 8D1107320486CEB800E47090 /* LineReader.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 29B97313FDCFA39411CA2CEA /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ ORGANIZATIONNAME = "Tobias Preuss";
+ };
+ buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "LineReader" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 29B97314FDCFA39411CA2CEA /* SequentialReader */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8D1107260486CEB800E47090 /* LineReader */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 8D1107290486CEB800E47090 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
+ 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8D11072C0486CEB800E47090 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8D11072D0486CEB800E47090 /* main.m in Sources */,
+ 256AC3DA0F4B6AC300CF3369 /* LineReaderAppDelegate.m in Sources */,
+ 558DC637125B369600AF819E /* DirectoryReader.m in Sources */,
+ 5548D857125B69B6001C6932 /* FileReader.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 089C165DFE840E0CC02AAC07 /* English */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 1DDD58140DA1D0A300B32029 /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 1DDD58150DA1D0A300B32029 /* English */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ C01FCF4B08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = LineReader_Prefix.pch;
+ INFOPLIST_FILE = "LineReader-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ PRODUCT_NAME = LineReader;
+ };
+ name = Debug;
+ };
+ C01FCF4C08A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = LineReader_Prefix.pch;
+ INFOPLIST_FILE = "LineReader-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ PRODUCT_NAME = LineReader;
+ };
+ name = Release;
+ };
+ C01FCF4F08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.6;
+ };
+ name = Debug;
+ };
+ C01FCF5008A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.6;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "LineReader" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4B08A954540054247B /* Debug */,
+ C01FCF4C08A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C01FCF4E08A954540054247B /* Build configuration list for PBXProject "LineReader" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4F08A954540054247B /* Debug */,
+ C01FCF5008A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
+}
22 LineReaderAppDelegate.h
@@ -0,0 +1,22 @@
+//
+// LineReaderAppDelegate.h
+// LineReader
+//
+// Created by Tobias Preuss on 05.10.10.
+// Copyright 2010 Tobias Preuss. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface LineReaderAppDelegate : NSObject <NSApplicationDelegate> {
+ NSWindow* window;
+ IBOutlet NSTextField* m_sourcePath;
+ IBOutlet NSTableView* m_tableView;
+ NSArray* m_directoryListing;
+}
+
+@property (assign) IBOutlet NSWindow *window;
+
+- (IBAction)sourcePathChanged:(id)sender;
+
+@end
60 LineReaderAppDelegate.m
@@ -0,0 +1,60 @@
+//
+// LineReaderAppDelegate.m
+// LineReader
+//
+// Created by Tobias Preuss on 05.10.10.
+// Copyright 2010 Tobias Preuss. All rights reserved.
+//
+
+#import "LineReaderAppDelegate.h"
+#import "DirectoryReader.h"
+#import "FileReader.h"
+
+
+
+/**
+ Application delegate.
+ */
+@implementation LineReaderAppDelegate
+
+
+@synthesize window;
+
+
+
+/**
+ Sent by the default notification center after the application
+ has been launched and initialized but before it has received
+ its first event.
+ @param aNotification A notification named NSApplicationDidFinishLaunchingNotification.
+ */
+- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
+}
+
+
+
+/**
+ Is called when the source path changes.
+ @param sender The object calling this method.
+ */
+- (IBAction)sourcePathChanged:(id)sender {
+
+ DirectoryReader* dr = [[DirectoryReader alloc] initWithPath:[m_sourcePath stringValue]];
+ if ([dr readDirectory:&m_directoryListing]) {
+ NSLog(@"%@",m_directoryListing); /* DEBUG LOG */
+
+ for (NSString* path in m_directoryListing) {
+
+ int numLines = 0;
+
+ FileReader* fr = [[FileReader alloc] initWithFilePath:path];
+ NSString* line = nil;
+ while (numLines <= 5 && (line = [fr readTrimmedLine])) {
+ NSLog(@"%@",line); /* DEBUG LOG */
+ numLines++;
+ }
+ }
+ }
+}
+
+@end
7 LineReader_Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'LineReader' target in the 'LineReader' project
+//
+
+#ifdef __OBJC__
+ #import <Cocoa/Cocoa.h>
+#endif
14 main.m
@@ -0,0 +1,14 @@
+//
+// main.m
+// LineReader
+//
+// Created by Tobias Preuss on 05.10.10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[])
+{
+ return NSApplicationMain(argc, (const char **) argv);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.