I've been trying to figure out how to do this also, except with returning a similar dictionary (as the second snippet of code) in the method (NSDictionary *)resourceAttributesAtPath:(NSString *)path error: (NSError **)error. This gets the custom icon displaying, but does not set the file as a directory.
On Jul 11, 12:25 pm, Sirui Sun <[email protected]> wrote: > Hi, > > I am new to MacFUSE and I've been trying to get custom folder icons to > work. Using the following code I have been able to get custom file > icons to work in the root directory: > > - (NSDictionary *)attributesOfItemAtPath:(NSString *)path > userData:(id)userData > error:(NSError **)error { > *error = [NSError errorWithPOSIXCode:ENOENT]; > > NSString *file = [[NSBundle mainBundle] > pathForResource:@"hellodoc" ofType:@"icns"]; > return [NSDictionary dictionaryWithObjectsAndKeys: > [NSData dataWithContentsOfFile:file], > kGMUserFileSystemCustomIconDataKey, nil]; > > } > > However, the only way that I've been able to make files into folders > is through adding the following object and key into the dictionary, so > the code looks like: > > - (NSDictionary *)attributesOfItemAtPath:(NSString *)path > userData:(id)userData > error:(NSError **)error { > *error = [NSError errorWithPOSIXCode:ENOENT]; > > NSString *file = [[NSBundle mainBundle] > pathForResource:@"hellodoc" ofType:@"icns"]; > return [NSDictionary dictionaryWithObjectsAndKeys: > [NSFileTypeRegular init],[NSFileType init], // > added this > [NSData dataWithContentsOfFile:file], > kGMUserFileSystemCustomIconDataKey, nil]; > > } > > Unfortunately, this seems to set the icon to the default folder icon. > Any suggestions? -- You received this message because you are subscribed to the Google Groups "MacFUSE" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/macfuse?hl=en.
