1 | | Index: Source/SpotlightFS.m |
2 | | =================================================================== |
3 | | --- Source/SpotlightFS.m (.../tags/macfuse-0.4.0/filesystems-objc/SpotlightFS) (revision 445) |
4 | | +++ Source/SpotlightFS.m (.../trunk/filesystems-objc/SpotlightFS) (revision 445) |
5 | | @@ -129,6 +129,25 @@ |
6 | | return userCreatedFolders; |
7 | | } |
8 | | |
9 | | +// -isUserCreatedFolder: |
10 | | +// |
11 | | +// Returns YES if the specified folder is a user created folder. Also try |
12 | | +// prepending a leading slash to the user created folders, incase |path| starts |
13 | | +// with a slash. |
14 | | +// |
15 | | +- (BOOL)isUserCreatedFolder:(NSString *)path { |
16 | | + NSArray *folders = [self userCreatedFolders]; |
17 | | + NSString *folder = nil; |
18 | | + NSEnumerator *folderEnumerator = [folders objectEnumerator]; |
19 | | + while ((folder = [folderEnumerator nextObject])) { |
20 | | + if ([folder isEqualToString:path]) |
21 | | + return YES; |
22 | | + if ([[@"/" stringByAppendingPathComponent:folder] isEqualToString:path]) |
23 | | + return YES; |
24 | | + } |
25 | | + return NO; |
26 | | +} |
27 | | + |
28 | | // -setUserCreatedFolders: |
29 | | // |
30 | | // Sets the folder names to use for the top-level user-created folders. |
31 | | @@ -341,20 +360,27 @@ |
32 | | return NO; |
33 | | } |
34 | | |
35 | | +// By default, directories are not writeable, with the notable exceptions below: |
36 | | +// - Slash is writable |
37 | | +// - User created directories in slash are writable |
38 | | - (NSDictionary *)fileAttributesAtPath:(NSString *)path { |
39 | | if (!path) |
40 | | return nil; |
41 | | |
42 | | NSMutableDictionary *attr = nil; |
43 | | + int mode = 0500; |
44 | | |
45 | | NSString *pathdir = [path stringByDeletingLastPathComponent]; |
46 | | NSString *smarter = [@"/" stringByAppendingString:kSmarterFolder]; |
47 | | |
48 | | - if ([pathdir isEqualToString:@"/"] |
49 | | - || [pathdir isEqualToString:smarter]) { |
50 | | + if ([pathdir isEqualToString:@"/"] || [pathdir isEqualToString:smarter]) { |
51 | | |
52 | | + if ([path isEqualToString:@"/"] || [self isUserCreatedFolder:path]) { |
53 | | + mode = 0700; |
54 | | + } |
55 | | + |
56 | | attr = [NSDictionary dictionaryWithObjectsAndKeys: |
57 | | - [NSNumber numberWithInt:0500], NSFilePosixPermissions, |
58 | | + [NSNumber numberWithInt:mode], NSFilePosixPermissions, |
59 | | [NSNumber numberWithInt:geteuid()], NSFileOwnerAccountID, |
60 | | [NSNumber numberWithInt:getegid()], NSFileGroupOwnerAccountID, |
61 | | [NSDate date], NSFileCreationDate, |
62 | | Index: Source/SpotlightFS.h |
63 | | =================================================================== |
64 | | --- Source/SpotlightFS.h (.../tags/macfuse-0.4.0/filesystems-objc/SpotlightFS) (revision 445) |
65 | | +++ Source/SpotlightFS.h (.../trunk/filesystems-objc/SpotlightFS) (revision 445) |
66 | | @@ -45,6 +45,10 @@ |
67 | | // |
68 | | - (NSArray *)userCreatedFolders; |
69 | | |
70 | | +// Returns YES if |path| is a user created folder. |
71 | | +// |
72 | | +- (BOOL)isUserCreatedFolder:(NSString *)path; |
73 | | + |
74 | | // Sets the full user-created folders array. |
75 | | // |
76 | | - (void)setUserCreatedFolders:(NSArray *)folders; |