Archived Forum Post

Index of archived forum posts

Question:

Permission denied Failed to open file

Apr 14 '15 at 12:53

In my cocoa application, i am trying to compress my .ps file using chilkat library. But some time (Rare case - lets say 5%) below issue occurs

> errno: 13 osErrorMessage: Permission
> denied Failed to open file. mode: r
> path:
> /private/var/spool/WQueue/Lilla/1427257004.ps
> --fopen_failed Failed to open file data source.
> 
> ChilkatLog: CompressFile: DllDate: Jul
> 21 2014 ChilkatVersion: 9.5.0.41
> UnlockPrefix: WNOZIP Architecture:
> Little Endian; 64-bit Language: Cocoa
> Objective-C VerboseLogging: 1 inPath:
> /private/var/spool/WQueue/Lilla/1427257004.ps
> outPath:
> /Users/Lilla/Library/Application
> Support/W/hub_1427257004.prn.zip
> fopen_failed: errno: 13
> osErrorMessage: Permission denied
> Failed to open file. mode: r path:
> /private/var/spool/WQueue/Lilla/1427257004.ps
> --fopen_failed Failed to open file data source. --CompressFile
> --ChilkatLog

At what time this type of issue occurs...? Chilkat, please provide the solution to accomplish this issue.


Answer

It's an OS error, meaning that the file is likely locked by another process or thread when you are trying to access it. You could test for this failure and retry after a short delay (perhaps a few times). If the failure continues for a certain period then you could alter the user.

Also, it might help to post the entire contents of the LastErrorText property rather than just a snippet.


Answer

The LastErrorText shows that Chilkat (internally) called the fopen function (http://www.cplusplus.com/reference/cstdio/fopen/ ) and the exact args passed were "r" for the access mode, and "/private/var/spool/WQueue/Lilla/1427257004.ps" for the path. The fopen system call returned NULL indicating failure, and the errno was set to 13, indicating "Permission denied". The "Permission denied" string is obtained by calling strerror(errno) (http://man7.org/linux/man-pages/man3/strerror.3.html )