Clash of UTIs

I have an application that is trying to register to open a UTI of a certain type. The official UTI for the document clashes with an obscure Quicktime format.

The file format I’m trying to use is a .dif file. Which is a “Data Interchange Format” file. Microsoft claims a UTI of:

com.microsoft.excel.dif

However, asking the system (mdls) about the format gives “public.dv-movie”, which traces back to:

public.dv-movie
public.movie
public.audiovisual-content
public.data
public.item
public.content

Finder will not recognise my file type request. I’ve tried specifying the Microsoft UTI and it fails to show the documents in Finder. I’ve tried making the file type “Unique to my application” and it still doesn’t show in the filtered open file dialog. Any suggestions welcome.

Try dropping one of these files onto the file type editor.

Thanks for that Greg, however, as I suspected that adds the UTI information for the DVmovie version of the type. Which I don’t support. Having it in the set at least makes the file viewable in the file browser. I suspect I’m going to have to leave it in there and check for the variety when loading.

If that’s the case then the file you are using is already tagged with the wrong UTI info. When you drag a file in, we actually ask the Finder what the file is and what UTI it is using.

Yes, as I said the file type is an old Microsoft Office format called “Data Interchange Format”. I don’t have office on my machine so it won’t have registered the type. There is a clash with the file extensions so .dif is this Microsoft format but is also used by Quicktime for an obscure primitive DVvideo format that is typically only found within a video container, however, Quicktime registers the format using a .dif extension on every Mac. Thus the start of the problem.

The good news is that if the UTIs are configured correctly in the app that creates these files, they’ll just work. File identification is a combination of extension and UTI these days and it is possible to have two types with the same extension as long as the UTI s are unique… but the system needs to know that they were created by your app. Not very good for cross-platform compatibility unfortunately.

Well, I still can’t get this to work correctly. If I only put my UTI in the application and make it owned by my app, declare it as an editor etc. I then create a file using the extension and it still comes out as a DV Video file. I’ve checked and the UTIs are registered on the computer.

Is there an extra step for creating the file other than simply opening the BinaryStream and writing the file. I have presented a SaveFileDialog and the user has selected a filename and choose the correct FileType. The FolderItem returned by the dialog has a ‘Type’ property that matches the DisplayName of the FileType.

Here is the DIF FileType:

and the standard filetype for my application, which works a treat:

a. Reboot the Computer
b. Rebuilt the Desktop (macOS)
c. Set all files as owned by your application (Get File Info window on Finder).

Ask for more explanation for points b and c if needed.

A and C are fine. I’ve not seen B for a very very long time. Likely since MacOS 9.

A and C didn’t help. The files do not show up in FileOpen dialog box, they don’t show my icon, only the QuickTime one. My application doesn’t show on the list of available applications that can open that kind of file. Even when I bypassed that in order to reallocate them to my application double-clicking did open the file in my app, however, it didn’t make it visible in the app in any other way. Also mdls still shows the application as belonging to QuickTime and having the QuickTime UTI.

Open the terminal and type mdls followed by the path to a file created by your application. You’ll get the UTIs in there that are being used.

As I said it comes out with the QuickTime one:

kMDItemContentType     = "public.dv-movie"
kMDItemContentTypeTree = (
    "public.dv-movie",
    "public.movie",
    "public.audiovisual-content",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemKind            = "DV movie"

Which isn’t even in my application.

Right, so that’s the problem. Now it could be that because QuickTime is an Apple product that they don’t allow other programs to take over their extensions at all. Or it could be that your UTI database is corrupt and not taking new entries. To check that, you’ll need access to another Mac to check its results against yours.

To do that, Open System Prefs (Control Panels…),
Click in Spotlight,
Click in panel 2 (Confidential ?)
Drop your hard disk in the list,
Wait a little bit (drink a beer or a coffee…)
Select the Hard Disk line,
Click in the minus sign (-),
Close the window and let the computer some times to do the job.

Eventually reboot and the “desktop” is rebuilt.

Just out of curiosity, what is the application identifier for your app?

The application identifier is “uk.ac.ox.dtu.cstat”, which is unique. I’ve tried creating a UTI of “uk.ac.ox.dtu.cstat.dif” incase that is required to match somehow for ownership.

It could be because it’s an Apple app, however, the dif extension dates back to the mid 80s so it’s not exactly theirs in the first place. I know that doesn’t usually stop Apple.

Ah, you mean to rebuilt the spotlight indexes. You can do that with a simple command line:

mdutil -E /

I’ve just started that off now. Once it is complete I will try again.

1 Like

@Greg_O_Lone
I’ve just make a quick sample application demonstrating the issue. I could log it as a bug if you wish.

The program has type FileTypes, one DIF and the other DOG. It has two buttons to create a file of each using a FileSaveDialog to do the work. It makes a dummy file and saves it. The DOG file works perfectly and DIF file doesn’t.

I notice that the FileTypeGroup editor creates UTIs with a format of

com.mycompany.utifail-dif

were the application is “com.mycompany.utifail”, is it meant to be that or should it be

com.mycompany.utifail.dif

I’ve tried both without help. I’ve also tried recreating the FileType completely from scratch.

I’m on Monterey, I’m happy to share the test application with anyone if they would like to test on a prior operating system version?

@Emile_Schwarz
I’ve rebuilt the Spotlight indexes and the situation remains the same.

I’ve just tried changing the extension and it works correctly. Even just changing .dif to .difa makes it work.

I also tried it on a second machine and it was exactly the same, however, it was also on Monterey.