Posts

Post marked as solved
4 Replies
105 Views
Hi, I'm trying to lock a file from objective-c (or plain C) so that other processes cannot read or write to it. So far, unsuccessfully. I've tried to use all APIs I can think of, but none locked the file: open then flock open then lockf open with O_EXLOCK open then fcntl (F_SETLK) open then NSDistributedLock I'm running macOS 11.6.1 on an APFS drive. For every API used, I was able to open and edit the file from command line using vi or just using cat on the file. Isn't there any way of preventing another process from accessing a file, until I'm done with it (ie. I closed the file, or the file handle is relinquished)? Thanks, Chris
Posted Last updated
.
Post not yet marked as solved
6 Replies
1.6k Views
Hi,my non-sandboxed application sometimes crashes with a NSInternalInconsistencyException, reason: 'placeholder directory popup view must be set up before making a filebrowser view', when calling [NSSavePanel savePanel].This is not happening 100% of the time (more 1%), and I cannot seem to find the reason for the crash.This is the crash backtrace:Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff8c2f62cb __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffa110648d objc_exception_throw + 48 2 CoreFoundation 0x00007fff8c2fb042 +[NSException raise:format:arguments:] + 98 3 Foundation 0x00007fff8dd43be0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 AppKit 0x00007fff8a804f4b -[NSSavePanel(FileBrowserViewFileBrowserView) _makeFileBrowserView] + 143 5 AppKit 0x00007fff8a46e2c0 -[NSSavePanel(NSSavePanelLayout) _setupFileBrowserView] + 169 6 AppKit 0x00007fff8a46f911 -[NSSavePanel(NSSavePanelLayout) _initContentView] + 5125 7 AppKit 0x00007fff8a45a83b -[NSSavePanel initWithContentRect:styleMask:backing:defer:] + 853 8 AppKit 0x00007fff89fb6c0f +[NSSavePanel _crunchyRawUnbonedPanel] + 518A detail that might have an importance, the call to [NSSavePanel savePanel] is make from a dylib, not from the main application module.Any idea?Thanks,Chris
Posted Last updated
.