-
-
Save mdippery/afd0ce88d3732c36a93b to your computer and use it in GitHub Desktop.
A test driver for my FileTailer class
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
#import <Foundation/Foundation.h> | |
#import "FileTailer.h" | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
FILE *in = stdin; | |
if (argc > 1) { | |
in = fopen(argv[1], "r"); | |
if (!in) { | |
fprintf(stderr, "Could not open file: %s\n", argv[1]); | |
[pool release]; | |
return 1; | |
} | |
} | |
FileTailer *tail = [[[FileTailer alloc] initWithStream:in refreshPeriod:3.0] autorelease]; | |
[tail readIndefinitely:^ void (int ch) { printf("%c", ch); }]; | |
[pool release]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment