0

There is an older thread here about creating temp files when developing Spotlight plugins using XCode.

In brief, in the GetMetadataForFile call, trying to create temp files/folders fails due to Spotlight sandboxing.

{
    NSString* tempDir = NSTemporaryDirectory();
    NSString* tempDirFolder = [tempDir stringByAppendingPathComponent:@"FinaleTempFiles"];

    NSError* theError = nil;

    BOOL fileOK = [[NSFileManager defaultManager] createDirectoryAtPath:tempDirFolder withIntermediateDirectories:NO attributes:nil error:&theError ];
    if ( !fileOK )
        NSLog(@"createDirectoryAtPath %@", [theError localizedDescription]);
}

NSLog output shows this Sandboxing violation:

2013-05-31 18:52:46.830 mdimport[43160:707] createDirectoryAtPath You don’t have permission to save the file “FinaleTempFiles” in the folder “T”.

I submitted a DTS ticket a few years ago, and essentially Apple admitted they weren't sure what they could do about it. If anyone has creative ideas on how to perform this, it would be extremely helpful.

If you're curious on why I'd like to do this, you can think (as an example) about running a shell command like unzip to extract a single file and then parsing it with another shell command.

dxdc
  • 435
  • 3
  • 8
  • Did you try the URL-equivalents of the filepaths? – Willeke Jun 20 '18 at 11:06
  • Thanks @Willeke .. yes, you can rerun [the entire source code here](http://www.cocoabuilder.com/archive/cocoa/328611-creating-temp-files-or-temp-folders-in-standard-temp-file-locations-in-mdimporter-on-mac-os-10-8-3.html) and get the same result. – dxdc Jun 21 '18 at 12:27

0 Answers0