NSFileWrapper, type & creator -> questions
NSFileWrapper, type & creator -> questions
- Subject: NSFileWrapper, type & creator -> questions
- From: Nick Müller <email@hidden>
- Date: Thu, 10 Jan 2002 16:07:32 +0100
Hi,
Reading the documentation for NSFileWrapper, it seems that it is
suitable for assigning creator codes to new files. But I can't.
Here is what I did:
Given:
creator: 'FooB'
application-name: "GreatApp"
icon: "GreatApp.icns"
file-extension: ".ext" // just kidding
Creating a new file
----
NSFileWrapper *file = [[NSFileWrapper alloc]
initWithRegularFileContents:nil];
NSMutableDirectory *attributes = [[NSMutableDirectory alloc] init];
[attributes setObject: [NSNumber numberWithUnsignedInt: 'FooB']
forKey:@"NSHFSCreatorCode"];
[attributes setObject: @"NSFileTypeRegular" forKey:@"NSFileType"];
[attributes setObject: [NSNumber numberWithUnsignedInt:0777]
forKey:@"NSFilePosixPermission"];
[file setFileAttributes: attributes];
[file writeToFile:@"file.ext" atomicaly:NO updateFilenames:YES];
----
This works partial as the file is created, but looking at the files
info, there is no creator and no icon.
OK, maybe I must do something more in the target settings of the
programm generating that file...
Target -> Application Settings (Expert mode)
CFBundleDocumentTypes
[one entry]
CFBundleTypeExtensions
[one entry]
"ext"
CFBundleTypeIconFile: "GreatApp.icns"
CFBundleTypeName: "GreatApp"
CFBundleTypeRole: "Editor"
Still not working. I can't find any examples, especially dealing with
NSFileWrapper:setFileAttributes that are using the creator code.
Yes, the file is on a HFS-volume.
What am I missing?
Another question is about extensions (duck):
As I can't be sure that no one other gets the idea to use ".ext" for his
files, how about using the assigned creator ("FooB") and hide the
extension?
TIA,
Nick
.........................................
logic tools
WebObjects // Web Authoring // Perl
Nick Mueller // Muenchen // Germany