• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Determining the size of a directory Part 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Determining the size of a directory Part 2
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: Determining the size of a directory Part 2
      • From: AndrĂ©as Saudemont <email@hidden>
    • Re: Determining the size of a directory Part 2
      • From: stephane sudre <email@hidden>
  • Prev by Date: Re: WebKit: Blanking the WebView
  • Next by Date: Re: Determining the size of a directory Part 2
  • Previous by thread: NSBrowser and setPath
  • Next by thread: Re: Determining the size of a directory Part 2
  • Index(es):
    • Date
    • Thread