site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914) Hi, I have an installer that works very well as long as I have 'Include Root in Package' enabled. When I disable it, the Icons for the app- lication bundle don't show up until the user reboots. The reason seems that PackageMaker creates the root folder (instead of unpacking it), and therefore the folder lacks attributes?! Using 'SetFile -a C /Applications/Folder.app' from a postinstall-script, I can make the Icons appear. However, SetFile is not available on the users machines. You can get a good starting with the code available at this URL: Your hint was actually very good, I changed a few lines of code and will now really distribute the little program with my installer. I have attached it, in case somebody can use a SetCustomIcon-cmdline- prog. Compile: gcc -o SetCustomIcon -framework CoreServices SetCustomIcon.c Note that for the sole purpose of having Finder refresh the icons, a simple 'touch' of the containing folder is sufficient. But for changing the Attribute you need SetFile of the little helper here. Cheers, /* * SetInvisible.c * Created by John R Chang on Wed May 26 2004. * This code is Creative Commons Public Domain. You may use it for any purpose whatsoever. * http://creativecommons.org/licenses/publicdomain/ * * Sets the Finder invisibility bit of a file/folder. * -v means make visible, -V means make invisible. * */ #include <CoreServices/CoreServices.h> #include <unistd.h> // getopt #include <stdlib.h> // realpath int main (int argc, const char * argv[]) { // Parse command-line arguments if (argc != 2) { printf("Please provide a path to a file/folder.\n"); return 1; } // Resolve specified path char* path = (char *)argv[1]; char* resolved_path = (char*)malloc(PATH_MAX); if (realpath(path, resolved_path) == NULL) { free(resolved_path); printf("Could not resolve path '%s'\n", path); return 1; } // Set the visibility FSRef ref; OSStatus status = FSPathMakeRef((unsigned char*)resolved_path, &ref, NULL); free(resolved_path); if (status != noErr) { printf("FSPathMakeRef failed\n"); return 1; } // Prepare to get the Finder info. FSCatalogInfoBitmap whichInfo = kFSCatInfoFinderInfo; FSCatalogInfo catalogInfo; // Now we need to set the file's Finder info so the Finder will know that // it has a custom icon. Start by getting the file's current finder info: status = FSGetCatalogInfo(&ref, whichInfo, &catalogInfo, /*outName*/ NULL, /*fsSpec*/ NULL, /*parentRef*/ NULL); if (status != noErr) { printf("FSGetCatalogInfo failed\n"); return 1; } FileInfo * finderInfo = (FileInfo *)&catalogInfo.finderInfo; //if (mode == 'v') // finderInfo->finderFlags &= ~kIsInvisible; // clear bit //else // finderInfo->finderFlags |= kIsInvisible; // set bit // Set the kHasCustomIcon flag, and clear the kHasBeenInited flag. // // From Apple's "CustomIcon" code sample: // "set bit 10 (has custom icon) and unset the inited flag // kHasBeenInited is 0x0100 so the mask will be 0xFEFF:" // finderInfo.fdFlags = 0xFEFF & (finderInfo.fdFlags | kHasCustomIcon ) ; finderInfo->finderFlags = (finderInfo->finderFlags | kHasCustomIcon ) & ~kHasBeenInited; status = FSSetCatalogInfo(&ref, whichInfo, &catalogInfo); if (status != noErr) { printf("FSSetCatalogInfo failed\n"); return 1; } return 0; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com Iceberg-Dev wrote: On Oct 23, 2008, at 7:01 PM, Mario Emmenlauer wrote: Whats the right tool to use on a users machine to set folder attributes? It's pretty easy to write one, you only need to play with the FSCatalogInfo data. http://homepage.mac.com/jrc/contrib/tools/SetInvisible.c Mario