Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (56 sloc) 2.111 kb
dc5be1c0 » uli
2009-07-04 Initial check-in.
1 //
2 // NSFileManager+VisibleDirectoryContents.m
3 // Shovel
4 //
5 // Created by Uli Kusterer on 01.10.04.
720b0e7b »
2010-03-04 Added licensing information to the source files.
6 // Copyright 2004 M. Uli Kusterer.
7 //
8 // This software is provided 'as-is', without any express or implied
9 // warranty. In no event will the authors be held liable for any damages
10 // arising from the use of this software.
11 //
12 // Permission is granted to anyone to use this software for any purpose,
13 // including commercial applications, and to alter it and redistribute it
14 // freely, subject to the following restrictions:
15 //
16 // 1. The origin of this software must not be misrepresented; you must not
17 // claim that you wrote the original software. If you use this software
18 // in a product, an acknowledgment in the product documentation would be
19 // appreciated but is not required.
20 //
21 // 2. Altered source versions must be plainly marked as such, and must not be
22 // misrepresented as being the original software.
23 //
24 // 3. This notice may not be removed or altered from any source
25 // distribution.
dc5be1c0 » uli
2009-07-04 Initial check-in.
26 //
27
28 #import "NSFileManager+VisibleDirectoryContents.h"
29 #import "NSString+CarbonUtilities.h"
30 #import <Carbon/Carbon.h>
31
32
33 @implementation NSFileManager (UKVisibleDirectoryContents)
34
35 -(NSArray*) visibleDirectoryContentsAtPath: (NSString*)path
36 {
37 NSDirectoryEnumerator* enny = [[NSFileManager defaultManager] enumeratorAtPath: path];
38 NSMutableArray* arr = [NSMutableArray array];
39 NSString* currFN;
40
41 while( (currFN = [enny nextObject]) )
42 {
43 [enny skipDescendents];
44 if( [currFN characterAtIndex: 0] == '.' )
45 continue;
46
47 FSRef fref;
48 FSCatalogInfo info;
49
50 if( [[path stringByAppendingPathComponent: currFN] getFSRef: &fref] )
51 {
52 if( noErr == FSGetCatalogInfo( &fref, kFSCatInfoFinderInfo, &info, NULL, NULL, NULL ) )
53 {
54 FileInfo* finderInfo = (FileInfo*)info.finderInfo;
55 if( (finderInfo->finderFlags & kIsInvisible) == kIsInvisible )
56 continue;
57 }
58 }
59
60 [arr addObject: currFN];
61 }
62
63 return arr;
64 }
65
66 @end
Something went wrong with that request. Please try again.