Re: File association using file magic
Op 22 jan. 2014, om 15:33 heeft Remco Poelstra re...@beryllium.net het volgende geschreven: I'm writing an app which has to import files without a fixed file extension. There are about 10 different commonly used file extensions around. Is it possible to associate a file to my app based on the file contents? Much like how file (1) determines a file's type? Or should I simply register all know file extensions? Thanks for both responses. I think I'll try to do both. Register all known file extensions, so the known ones get a nice document icon and the suggestion to open it with my app. And accept all other types, just in case someone comes up with a new extension. I think that will be the most useful to users. Regards, Remco Poelstra ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On 22 Jan 2014, at 15:33, Remco Poelstra re...@beryllium.net wrote: I'm writing an app which has to import files without a fixed file extension. There are about 10 different commonly used file extensions around. You can specify a whole list of file extensions in your Info.plist for each document class. That way they get an icon, can be double-clicked to open in your app etc. Is it possible to associate a file to my app based on the file contents? Much like how file (1) determines a file's type? Nope. Or should I simply register all know file extensions? That's the preferred solution. How common is it that files have an extension that is not on your list, or even no extension at all? If it's just something some weird people do, then rest assured we all have to cope with those people. Just tell them to re-add your preferred extension. If it's a little more common, you can also take advantage of command-drag support: If you hold down the command key while dragging a file on an application icon, it will be opened in your application, regardless of its filename suffix (You may have to override application:openFile: in your app delegate to apply a default file type in this case, though). So if this is a rare case, you can probably give this workaround to any users that have this problem. That's better than accepting any old file (e.g. by registering for creator code ''), and having to cope with completely wrong files someone just tried dragging on your app icon. -- Uli Kusterer The Witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Fri, 24 Jan 2014 10:04:05 +0100, Remco Poelstra said: Thanks for both responses. I think I'll try to do both. Register all known file extensions, so the known ones get a nice document icon and the suggestion to open it with my app. And accept all other types, just in case someone comes up with a new extension. I think that will be the most useful to users. Are those extensions unique or common? For example, is .img one of the extensions people use for these files? Over the years, .img and other extensions, have been used by many different file formats. OS X has a one-to-one mapping of extension to UTI and so doesn't deal well if two different applications declaring different UTIs for the same extension. Just another case to look out for... Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On 2014 Jan 24, at 08:56, Sean McBride s...@rogue-research.com wrote: OS X has a one-to-one mapping of extension to UTI and so doesn't deal well if two different applications declaring different UTIs for the same extension. Just another case to look out for… In particular, prepare for support requests from users complaining “Why does your damned app launch every time I double-click a .whatever file?” Out in the wild, people will • Forget that they have your app • Forget what it was for • Ditto for other apps claiming the same .whatever ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 1:30 PM, Jerry Krinock je...@ieee.org wrote: On 2014 Jan 24, at 08:56, Sean McBride s...@rogue-research.com wrote: OS X has a one-to-one mapping of extension to UTI and so doesn't deal well if two different applications declaring different UTIs for the same extension. Just another case to look out for… In particular, prepare for support requests from users complaining “Why does your damned app launch every time I double-click a .whatever file?” Out in the wild, people will • Forget that they have your app • Forget what it was for • Ditto for other apps claiming the same .whatever I personally hate this, especially if your app reads file types other apps share with you. For instance, one of my programs opens ISO files, and one user emailed to tell me my app was opening every time he clicked on it. Now, it was his fault, as he set the file association, but he blamed me. Users can be so annoying sometimes. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/sevenbitstech%40gmail.com This email sent to sevenbitst...@gmail.com signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 1:25 PM, SevenBits sevenbitst...@gmail.com wrote: I personally hate this, especially if your app reads file types other apps share with you. For instance, one of my programs opens ISO files, and one user emailed to tell me my app was opening every time he clicked on it. Now, it was his fault, as he set the file association, but he blamed me. Users can be so annoying sometimes. Not necessarily the user's fault; I've seen it happen often that LaunchServices just decides to make some other app the default, even though there's an OS-provided app that really *should* remain the default until someone explicitly changes it. This is particularly bad for the apps that live in /System/Library/CoreServices (like DiskImageMounter, in your ISO example), as some of those seem to be still using CFBundleTypeExtensions in their CFBundleDocumentTypes dictionary instead of a UTI, and LS always seems to prefer apps that use UTI over ones that don't if no explicit default is set, so if your app uses a UTI for those types, control will be handed over to you instead of DiskImageMounter simply because the user downloaded your app. My solution was just to check the file associations on startup, and if it's set to me, change it back to the OS-provided app. It's a kludge, but it's stopped the angry e-mails, and all is right with the world. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 4:49 PM, Charles Srstka cocoa...@charlessoft.com wrote: On Jan 24, 2014, at 1:25 PM, SevenBits sevenbitst...@gmail.com wrote: I personally hate this, especially if your app reads file types other apps share with you. For instance, one of my programs opens ISO files, and one user emailed to tell me my app was opening every time he clicked on it. Now, it was his fault, as he set the file association, but he blamed me. Users can be so annoying sometimes. Not necessarily the user's fault; I've seen it happen often that LaunchServices just decides to make some other app the default, even though there's an OS-provided app that really *should* remain the default until someone explicitly changes it. This is particularly bad for the apps that live in /System/Library/CoreServices (like DiskImageMounter, in your ISO example), as some of those seem to be still using CFBundleTypeExtensions in their CFBundleDocumentTypes dictionary instead of a UTI, and LS always seems to prefer apps that use UTI over ones that don't if no explicit default is set, so if your app uses a UTI for those types, control will be handed over to you instead of DiskImageMounter simply because the user downloaded your app. Wow, I’ve never heard about that. That’s quite problematic. My solution was just to check the file associations on startup, and if it's set to me, change it back to the OS-provided app. It's a kludge, but it's stopped the angry e-mails, and all is right with the world. I *would* do that, but the app in question is sandboxed, so it surely can’t change users’ preferences. Oh, the agony! :) Charles signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 5:53 PM, SevenBits sevenbitst...@gmail.com wrote: On Jan 24, 2014, at 4:49 PM, Charles Srstka cocoa...@charlessoft.com wrote: On Jan 24, 2014, at 1:25 PM, SevenBits sevenbitst...@gmail.com wrote: I personally hate this, especially if your app reads file types other apps share with you. For instance, one of my programs opens ISO files, and one user emailed to tell me my app was opening every time he clicked on it. Now, it was his fault, as he set the file association, but he blamed me. Users can be so annoying sometimes. Not necessarily the user's fault; I've seen it happen often that LaunchServices just decides to make some other app the default, even though there's an OS-provided app that really *should* remain the default until someone explicitly changes it. This is particularly bad for the apps that live in /System/Library/CoreServices (like DiskImageMounter, in your ISO example), as some of those seem to be still using CFBundleTypeExtensions in their CFBundleDocumentTypes dictionary instead of a UTI, and LS always seems to prefer apps that use UTI over ones that don't if no explicit default is set, so if your app uses a UTI for those types, control will be handed over to you instead of DiskImageMounter simply because the user downloaded your app. Wow, I’ve never heard about that. That’s quite problematic. One caveat, of course, is that I haven't tested this on Mavericks, so it's possible that this may have changed. It was definitely behaving that way on previous OS X versions, reproducibly. I thought I had filed a Radar on this, but now I can't find it in my history. :-/ My solution was just to check the file associations on startup, and if it's set to me, change it back to the OS-provided app. It's a kludge, but it's stopped the angry e-mails, and all is right with the world. I *would* do that, but the app in question is sandboxed, so it surely can’t change users’ preferences. Oh, the agony! :) Well, that's for a good reason, you see. If your app were able to change users' preferences, it might be able to... erm... take over... uh... file associations. Hrm. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 5:27 PM, Charles Srstka cocoa...@charlessoft.com wrote: Well, that's for a good reason, you see. If your app were able to change users' preferences, it might be able to... erm... take over... uh... file associations. Hrm. You don’t see that as a problem? Install SuperFunGame from the App Store. It associates itself with the com.intuit.QuickBooks UTI. Next time you double-click your QuickBooks file in Finder, SuperFunGame gets the `open` event, and takes the liberty of sending home all your employees’ Social Security numbers before re-opening the file in QuickBooks. Seem far-fetched? Well, the Internet Security 2003 malware for Windows does the exact same thing, except for *all executables* on the system: http://malwaretips.com/blogs/internet-security-2013-virus/ --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 10:02 PM, Kyle Sluder k...@ksluder.com wrote: On Jan 24, 2014, at 5:27 PM, Charles Srstka cocoa...@charlessoft.com wrote: Well, that's for a good reason, you see. If your app were able to change users' preferences, it might be able to... erm... take over... uh... file associations. Hrm. You don’t see that as a problem? Install SuperFunGame from the App Store. It associates itself with the com.intuit.QuickBooks UTI. Next time you double-click your QuickBooks file in Finder, SuperFunGame gets the `open` event, and takes the liberty of sending home all your employees’ Social Security numbers before re-opening the file in QuickBooks. Seem far-fetched? Well, the Internet Security 2003 malware for Windows does the exact same thing, except for *all executables* on the system: http://malwaretips.com/blogs/internet-security-2013-virus/ One of the enormously fun things I miss about Windows (not!). Sad to see we’re starting to see this in the Mac world now too. --Kyle Sluder signature.asc Description: Message signed with OpenPGP using GPGMail ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 24, 2014, at 9:02 PM, Kyle Sluder k...@ksluder.com wrote: On Jan 24, 2014, at 5:27 PM, Charles Srstka cocoa...@charlessoft.com wrote: Well, that's for a good reason, you see. If your app were able to change users' preferences, it might be able to... erm... take over... uh... file associations. Hrm. You don’t see that as a problem? Install SuperFunGame from the App Store. It associates itself with the com.intuit.QuickBooks UTI. Next time you double-click your QuickBooks file in Finder, SuperFunGame gets the `open` event, and takes the liberty of sending home all your employees’ Social Security numbers before re-opening the file in QuickBooks. Seem far-fetched? Well, the Internet Security 2003 malware for Windows does the exact same thing, except for *all executables* on the system: http://malwaretips.com/blogs/internet-security-2013-virus/ --Kyle Sluder Of course it's a problem; I was being more than a little facetious there. If you read the thread, you'll see that we've been talking about a way to take over file associations that's so easy to do, you can do it by accident — even if sandboxed. I don't use QuickBooks, but given how horribly out of date certain other Intuit products tend to be on the Mac, I wouldn't be one bit surprised if it were registering its document types via extension instead of UTI, and even if it doesn't, there's probably some older version that some users have that does, or perhaps there's some other application on the hard drive that's using filename extensions somewhere that's also in charge of some data you wouldn't want to leak out. All HappyFunGame has to do is register for a UTI for that type (defining one if it doesn't already exist for that extension) and LaunchServices will go Oh, LegitApp registers for the extension, HappyFunGame registers for the UTI — better give it to HappyFunGame! The thing that's disturbing is that you can do this; the thing that's irritating is that if you do this accidentally, you're prevented from undoing it by the very mechanism that was supposed to stop you from doing it in the first place. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 22, 2014, at 8:33 AM, Remco Poelstra wrote: I'm writing an app which has to import files without a fixed file extension. There are about 10 different commonly used file extensions around. Is it possible to associate a file to my app based on the file contents? Much like how file (1) determines a file's type? No. Or should I simply register all know file extensions? That or accept all file types and then check the contents to decide if you can open the file. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File association using file magic
On Jan 22, 2014, at 8:33 AM, Remco Poelstra re...@beryllium.net wrote: I'm writing an app which has to import files without a fixed file extension. There are about 10 different commonly used file extensions around. Is it possible to associate a file to my app based on the file contents? Much like how file (1) determines a file's type? Or should I simply register all know file extensions? Is this a standard type that just happens to have multiple filename extensions associated with it (like .jpg and .jpeg for JPEG files)? If so, there might be a UTI for that type, which you can just register for instead of registering for the filename extension directly. If the type has no existing UTI (for example, if it's a type specific to your app), you can define your own UTI for it, and list the file extensions it uses in the UTI definition. Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com