Determining the size of a directory Part 2
Determining the size of a directory Part 2
- Subject: Determining the size of a directory Part 2
- From: Dominik Freyer <email@hidden>
- Date: Mon, 25 Oct 2004 14:42:36 +0200
Hi everybody,
I'm still trying to get the size of a directory. After some tips from
this List I tried to use the 'du' command line utility which works very
fast. I wanted to use it as an NSTask. Now I've got the problem, that I
don't get any data back from the utility. I think I set the FileHandle
correctly. Somehow, the programm begins to spin when reaching the line
duOutput=[fromDu readDataOfLength:10]; I checked in the debugger and to
me it seems like it just waits.
Here is the complete method:
- (unsigned long long)getSizeOfDirectory:(NSString*)path
{
NSAutoreleasePool *poolForSize=[[NSAutoreleasePool alloc]init];
NSArray *args;
NSPipe *fromPipe;
NSFileHandle *fromDu;
NSData *duOutput;
unsigned char aBuffer[70];
args = [NSArray arrayWithObjects:@"-ks",path,nil];
fromPipe=[NSPipe pipe];
fromDu=[[NSFileHandle alloc]init];
fromDu=[fromPipe fileHandleForReading];
NSTask *duTool=[[NSTask alloc]init];
[duTool setLaunchPath:@"/usr/bin/du"];
[duTool setStandardOutput:fromDu];
[duTool setArguments:args];
[duTool launch];
duOutput=[fromDu readDataOfLength:10];
[duOutput getBytes:aBuffer];
unsigned long long output=123;
return (unsigned long long)output;
[duTool release];
[poolForSize release];
}
Any ideas? Thanks in advance
Dominik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden