Skip navigation.
 
mlRe: Determining the size of a directory Part 2
FROM : Dominik Freyer
DATE : Mon Oct 25 15:48:24 2004

>
> Use the POSIX API?
>


@stephane: Can I simply call this method out of Cocoa?

@andreas:

> Hi Dominik,
>
> I guess you should connect the output file handle of 'fromPipe' (as
> returned by fileHandleForWriting), and not its input file handle, to
> the standard output of 'duTool'. Then you can use 'fromDu' to read
> data from the pipe.


Ok, i changed it to this:

    args = [NSArray arrayWithObjects:@"-ks",path,nil];
    fromPipe=[NSPipe pipe];
    // fromDu=[[NSFileHandle alloc]init];
    fromDu=[fromPipe fileHandleForWriting];
    NSTask *duTool=[[NSTask alloc]init];


Did you talk of this? And is the memory leak now repaired?

>
> By the way you're leaking memory in the following code:
>

>>      fromDu=[[NSFileHandle alloc]init];
>>      fromDu=[fromPipe fileHandleForReading];

>
> And releasing 'duTool' and 'poolForSize' after returning won't be very
> helpful:
>

>>      return (unsigned long long)output;
>>      [duTool release];
>>      [poolForSize release];


Ok, I put it before the return, hope this helps.

Anyway, I'm getting a *** Uncaught exception:
<NSFileHandleOperationException> *** -[NSConcreteFileHandle
readDataOfLength:]: Bad file descriptor

I'm now using readDataToEndOfFile


@Finley: I'm not using fts because I didn't know about it. :-) Do I
loose something when using du instead of fts?

Thanks for all your fast responses

Dominik

Related mailsAuthorDate
mlDetermining the size of a directory Part 2 Dominik Freyer Oct 25, 14:42
mlRe: Determining the size of a directory Part 2 stephane sudre Oct 25, 14:50
mlRe: Determining the size of a directory Part 2 Andréas Saudemont Oct 25, 14:56
mlRe: Determining the size of a directory Part 2 Andréas Saudemont Oct 25, 15:04
mlRe: Determining the size of a directory Part 2 M. Uli Kusterer Oct 25, 15:10
mlRe: Determining the size of a directory Part 2 Finlay Dobbie Oct 25, 15:30
mlRe: Determining the size of a directory Part 2 Dominik Freyer Oct 25, 15:48
mlRe: Determining the size of a directory Part 2 Andréas Saudemont Oct 25, 16:29
mlRe: Determining the size of a directory Part 2 Dominik Freyer Oct 25, 16:42
mlRe: Determining the size of a directory Part 2 stephane sudre Oct 25, 17:17
mlRe: Determining the size of a directory Part 2 Finlay Dobbie Oct 25, 18:57
mlRe: Determining the size of a directory Part 2 Dominik Freyer Oct 25, 20:52
mlRe: Determining the size of a directory Part 2 Darkshadow Oct 26, 02:46
mlRe: Determining the size of a directory Part 2 Finlay Dobbie Oct 26, 12:38