I have a strange error when resolving a security-scoped bookmark (SSB) in my screensaver.
The code works fine for almost all users (even under Mojave), except for one user under Mojave (10.14.6).
Here is the code in question:
The method returns NULL, and error says:
The SSB points to a directory in the user's home.
I can see that in the log, because in my code I do
and then I output [dict objectForKey: NSURLPathKey] .
The user has opened the directory in the previous run, and I am creating and storing an SSB with this code:
and it seems to work just fine.
I don't know whether or not it matters: the error occurs in a screensaver of mine, i.e., it occurs when the users launches the screensaver moving the mouse into the respective hot corner.
But the SSB is created and resolved by exactly the same .saver executable.
Does anyone have an idea why -URLByResolvingBookmarkData might fail?
Or could some kind soul give me hints how I might be able to track down the bug?
(Of course, I tried to google, to no avail.)
I am at a loss here ...
Thanks a lot in advance.
Best regards, Gabriel
The code works fine for almost all users (even under Mojave), except for one user under Mojave (10.14.6).
Here is the code in question:
Code Block NSError * error; BOOL isStale = NO; NSURL * dir_location = [NSURL URLByResolvingBookmarkData: bookmark options: NSURLBookmarkResolutionWithSecurityScope relativeToURL: nil bookmarkDataIsStale: & isStale error: & error];
The method returns NULL, and error says:
Code Block Error Domain=NSCocoaErrorDomain Code=259 "The file couldn't be opened because it isn't in the correct format."
The SSB points to a directory in the user's home.
I can see that in the log, because in my code I do
Code Block NSDictionary * dict = [NSURL resourceValuesForKeys: [NSArray arrayWithObjects: NSURLPathKey, nil] fromBookmarkData: bookmark ];
and then I output [dict objectForKey: NSURLPathKey] .
The user has opened the directory in the previous run, and I am creating and storing an SSB with this code:
Code Block NSError * systemError; NSData * dir_bookmark = [dir bookmarkDataWithOptions: NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys: nil relativeToURL: nil error: &systemError];
and it seems to work just fine.
I don't know whether or not it matters: the error occurs in a screensaver of mine, i.e., it occurs when the users launches the screensaver moving the mouse into the respective hot corner.
But the SSB is created and resolved by exactly the same .saver executable.
Does anyone have an idea why -URLByResolvingBookmarkData might fail?
Or could some kind soul give me hints how I might be able to track down the bug?
(Of course, I tried to google, to no avail.)
I am at a loss here ...
Thanks a lot in advance.
Best regards, Gabriel