2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/Foundation.h>
23 #import <EOControl/EOControl.h>
24 #include <NGExtensions/NSFileManager+Extensions.h>
25 #include <NGExtensions/NGFileFolderInfoDataSource.h>
26 #include <NGExtensions/NGDirectoryEnumerator.h>
28 @interface TestDirEnumTool : NSObject
31 @implementation TestDirEnumTool
33 - (void)runWithArguments:(NSArray *)args {
35 NGDirectoryEnumerator *e;
38 fm = [NSFileManager defaultManager];
40 e = [[NGDirectoryEnumerator alloc] initWithFileManager:fm
41 directoryPath:[args objectAtIndex:1]];
43 NSLog(@"enum: %@", e);
45 while ((cpath = [e nextObject])) {
47 printf("%s\n", [cpath cString]);
51 record = [e fileAttributes];
53 /* id uid gid date name */
62 fileId = [[record objectForKey:NSFileIdentifier] description];
63 owner = [record objectForKey:NSFileOwnerAccountName];
64 gid = [[record objectForKey:NSFileGroupOwnerAccountNumber] intValue];
65 size = [[record objectForKey:NSFileSize] intValue];
66 modDate = [[record objectForKey:NSFileModificationDate] description];
67 fname = [record objectForKey:NSFileName];
68 ftype = [record objectForKey:NSFileType];
70 if ([ftype isEqualToString:NSFileTypeDirectory])
71 fname = [fname stringByAppendingString:@"/"];
72 else if ([ftype isEqualToString:NSFileTypeSocket])
73 fname = [fname stringByAppendingString:@"="];
74 else if ([ftype isEqualToString:NSFileTypeSymbolicLink])
75 fname = [fname stringByAppendingString:@"@"];
77 //NSLog(@"record: %@", record);
79 printf("%8s %8s %8i %8i %8s %s\n",
91 @end /* TestDirEnumTool */
93 int main(int argc, char **argv, char **env) {
94 NSAutoreleasePool *pool;
98 pool = [[NSAutoreleasePool alloc] init];
99 #if LIB_FOUNDATION_LIBRARY
100 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
103 args = [[NSProcessInfo processInfo] arguments];
104 if ([args count] < 1) {
105 NSLog(@"usage: %@ dir", [args objectAtIndex:0]);
108 else if ([args count] == 1)
109 args = [args arrayByAddingObject:@"."];
111 tool = [[TestDirEnumTool alloc] init];
112 [tool runWithArguments:args];