I would like to load a text file using BIO_new_file(myPath, "r") in objective-c.
As path I obtain the current document directory from the bundle.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [NSString stringWithFormat:@"%@/test.txt", documentsDirectory];
NSLog(@"%@", fileName);
const char* cString = [fileName cStringUsingEncoding:NSUTF8StringEncoding];
BIO *temp = BIO_new_file(cString, "r");
if (!temp) {
NSLog(@"Could not load file!");
assert(false);
}
But the method couldn’t load the file and I receive the Could not load file!.
Is this a known issue when using Openssl’s BIO in objective-c? Are there any workarounds?
Perhaps there is no file named
test.txtin your application’s documents directory. Try logging the error code: