Use fopen function in iOS system and fopen function in ios system
When openssl codec is used in the application these days, if the FILE cannot be obtained by opening the FILE with fopen, crash will be solved. The following is a record:
Because some code at the bottom layer of the application is written in C, you need to open a file to read data. NSURL is used when creating a file in Objective-C at the beginning, [[url absoluteString] UTF8String] is used for uploading to the C code. The fd obtained during fopen is-1 and the file is not opened.
When tracking the code, it is found that the NSURL points to the file path in the format of file: // xxxx, but if the NSString points to the file path is/file/xxxx, in UNIX file systems, the former cannot locate a file,Finally, you can use NSString to point to the file by modifying the method of creating and obtaining the file. You must never use NSURL.
Files placed under Document and tmp are not affected.
The above are the lessons learned to solve this problem. It took 30 minutes to discover the lessons of blood. Hope to help you.