Hi all,

I posted this originally on the spotlight-dev list but now that I have some 
sample code that is failing and it is starting to look like a sandboxing issue, 
I thought I'd try the cocoa-dev list where I have been seeing some spotlight 
questions too.

Basically, the subject says it all.  We are having problems with our Spotlight 
importer when creating temp files or temp folders in the standard temp file 
locations under Mac OS X 10.8.3/Xcode 4.6.2.  Everything works fine under Mac 
OS X 10.7.5/Xcode 4.5.2  I've re-read the entire Spotlight Importer Programming 
Guide and didn't find any help there, no information mentioned about sandbox 
issues.  I still suspect an app sandbox-like issue but would like more 
information on this.  Here is some sample code I ran at the beginning of our 
importer right when we get the GetMetadataForFile call:

    {
        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]);
    }

    {
        NSURL* tempDir = [NSURL fileURLWithPath:NSTemporaryDirectory()];
        NSURL* tempDirFolder = [tempDir 
URLByAppendingPathComponent:@"FinaleTempFiles"];

        NSError* theError = nil;

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

    {
        NSString* tempDir = NSTemporaryDirectory();
        NSString* tempDirFile = [tempDir 
stringByAppendingPathComponent:@"EmptyFile"];

        NSData* emptyContents = [[NSData alloc] init];

        BOOL success = [[NSFileManager defaultManager] 
createFileAtPath:tempDirFile contents:emptyContents attributes:nil];

        if ( !success )
            NSLog(@"createFileAtPath: Error was code: %d - message: %s", errno, 
strerror(errno));
    }

    {
        NSURL* tempDir = [NSURL fileURLWithPath:NSTemporaryDirectory()];
        NSURL* tempDirFile = [tempDir URLByAppendingPathComponent:@"EmptyFile"];

        NSData* emptyContents = [[NSData alloc] init];

        NSError *theError = nil;
        BOOL success = [emptyContents writeToURL:tempDirFile 
options:NSDataWritingAtomic error:&theError];
        if ( !success )
            NSLog(@"writeToURL %@ ", [theError localizedDescription]);
    }

and the corresponding NSLog output:

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”.
2013-05-31 18:52:50.446 mdimport[43160:707] createDirectoryAtURL You don’t have 
permission to save the file “FinaleTempFiles” in the folder “T”.
2013-05-31 18:52:57.821 mdimport[43160:707] createFileAtPath: Error was code: 1 
- message: Operation not permitted
2013-05-31 18:53:07.692 mdimport[43160:707] writeToURL You don’t have 
permission to save the file “EmptyFile”.

I get the same output for our 32-bit and 64-bit builds.  Surely we must still 
be able to create temp files?

Thanks,
Chris

_________________________________

Chris Cianflone
Senior Software Engineer
www.makemusic.com<http://www.makemusic.com>


_______________________________________________

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

Reply via email to