My FileProviderExtension should allow creating folders in the root level, but not files. Is there a way to achieve that?
I tried creating a NSFileProviderUserInteractions
entry like
<dict>
<key>ActivationRule</key>
<string>(action == "Create" OR action == "MoveIn" OR action == "CopyIn") AND destinationItem.itemIdentifier == "NSFileProviderRootContainerItemIdentifier"</string>
<key>SubInteractions</key>
<array>
<dict>
<key>ActivationRule</key>
<string>TRUEPREDICATE</string>
<key>Alert</key>
<dict>
<key>LocalizedRecoveryOptions</key>
<dict>
<key>Cancel</key>
<string>OK</string>
</dict>
<key>LocalizedSubTitle</key>
<string>Files cannot be added to root level.</string>
<key>LocalizedTitle</key>
<string>Forbidden action</string>
<key>RecoveryOptions</key>
<dict>
<key>Continue</key>
<false/>
</dict>
</dict>
</dict>
</array>
</dict>
but this prevents creation of both files and folders in the root level. How to just prevent file creation?
Probably relevant: Apple NSFileProviderItem.h states for 'Create':
'Create': creating an item (available in macOS 12.0 and later) The Create action will be evaluated when the user creates a new file or folder in a system Open/Save panel. The sourceItem is the file/folder being created. The only field that is populated for this item is the filename. The type of file/folder, size, etc, are unknown at Create evaluation time. The destinationItem is the directory which the file/folder is being created within.
Does this mean that whether it is a file or a folder which is being created is unknown at 'Create' time? I find that quite weird and if that is the case then this cannot be supported?