gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDirectoryEnumerator


From: Yen-Ju Chen
Subject: Re: NSDirectoryEnumerator
Date: Fri, 1 Oct 2004 14:39:03 -0400

On Fri, 01 Oct 2004 20:49:38 +0300, Enrico Sersale <address@hidden> wrote:
> 
> #include <Foundation/Foundation.h>
> 
> static NSString *outpath = @"/home/enrico/enumerator.out"; // put here your 
> path
> 
> int main(int argc, char** argv)
> {
>    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] 
> enumeratorAtPath: @"/"];
>    NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath: outpath];
>    NSStringEncoding encoding = [NSString defaultCStringEncoding];
>    NSString *path;
> 
>    while ((path = [enumerator nextObject])) {
>      if ([[enumerator fileAttributes] fileType] == NSFileTypeDirectory) {
>        path = [path stringByAppendingString: @"\n"];
>        [handle writeData: [path dataUsingEncoding: encoding]];
>      }
>    }
> 
>    [handle closeFile];
>    [pool release];
> 
>    return 0;
> }
> 

  I did a quick test on FreeBSD 4.10 with GNUstep CVS Aug 30.
  The result is almost the same.
  The difference (less than 10) is due to the /proc or /tmp.
  I did not write to a file using NSHandle.
  Instead, I use NSLog or printf() to output the path and redirect
them to a file.

  Yen-Ju




reply via email to

[Prev in Thread] Current Thread [Next in Thread]