2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #import <Foundation/Foundation.h>
24 #import <EOControl/EOControl.h>
25 #include <NGExtensions/NSFileManager+Extensions.h>
26 #include <NGExtensions/NGFileFolderInfoDataSource.h>
27 #include <NGExtensions/NGDirectoryEnumerator.h>
29 @interface TestDirEnumTool : NSObject
32 @implementation TestDirEnumTool
34 - (void)runWithArguments:(NSArray *)args {
36 NGDirectoryEnumerator *e;
39 fm = [NSFileManager defaultManager];
41 e = [[NGDirectoryEnumerator alloc] initWithFileManager:fm
42 directoryPath:[args objectAtIndex:1]];
44 NSLog(@"enum: %@", e);
46 while ((cpath = [e nextObject])) {
48 printf("%s\n", [cpath cString]);
52 record = [e fileAttributes];
54 /* id uid gid date name */
63 fileId = [[record objectForKey:NSFileIdentifier] description];
64 owner = [record objectForKey:NSFileOwnerAccountName];
65 gid = [[record objectForKey:NSFileGroupOwnerAccountNumber] intValue];
66 size = [[record objectForKey:NSFileSize] intValue];
67 modDate = [[record objectForKey:NSFileModificationDate] description];
68 fname = [record objectForKey:NSFileName];
69 ftype = [record objectForKey:NSFileType];
71 if ([ftype isEqualToString:NSFileTypeDirectory])
72 fname = [fname stringByAppendingString:@"/"];
73 else if ([ftype isEqualToString:NSFileTypeSocket])
74 fname = [fname stringByAppendingString:@"="];
75 else if ([ftype isEqualToString:NSFileTypeSymbolicLink])
76 fname = [fname stringByAppendingString:@"@"];
78 //NSLog(@"record: %@", record);
80 printf("%8s %8s %8i %8i %8s %s\n",
92 @end /* TestDirEnumTool */
94 int main(int argc, char **argv, char **env) {
95 NSAutoreleasePool *pool;
99 pool = [[NSAutoreleasePool alloc] init];
100 #if LIB_FOUNDATION_LIBRARY
101 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
104 args = [[NSProcessInfo processInfo] arguments];
105 if ([args count] < 1) {
106 NSLog(@"usage: %@ dir", [args objectAtIndex:0]);
109 else if ([args count] == 1)
110 args = [args arrayByAddingObject:@"."];
112 tool = [[TestDirEnumTool alloc] init];
113 [tool runWithArguments:args];