Objective-c 从包中加载 BIO
我想在 Objective-C 中使用 BIO_new_file(myPath, "r")
加载一个文本文件。 作为路径,我从包中获取当前文档目录。
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);
}
但该方法无法加载文件,并且我收到无法加载文件!
。
在 Objective-C 中使用 Openssl 的 BIO 时,这是一个已知问题吗?有什么解决方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您的应用程序的文档目录中没有名为
test.txt
的文件。尝试记录错误代码:Perhaps there is no file named
test.txt
in your application's documents directory. Try logging the error code: