将文件写入越狱电话的根目录中,允许吗? [英] write the files in root directory in jailbreak phone,permitted?
问题描述
我的手机已越狱,我想在/var/mobile/Documents/
中写入文件,我使用NSFileManager
正常工作,但无法正常工作,我打印error
日志为操作无法完成. 不允许操作",好吧,我想NSFileManager
只能在sandbox
中使用,也许我在使用C(fread和fwrite),但是文件也只能读取,不能写入,如何修复它,我只想将文件写到我的应用程序sandbox
目录的外部吗?
my phone was jailbreak,I want to write the files in /var/mobile/Documents/
, I using the NSFileManager
to working,but it cant working, I print the error
log was "The operation couldn’t be completed. Operation not permitted", ok,I think NSFileManager
just can using in sandbox
maybe that I using the C(fread and fwrite), but also the file just can read,cant write,how to fix it,I just want write the file to the outside of the sandbox
directory in my app?
推荐答案
您是否尝试过使用默认的C标准IO方法?过去,这对我来说非常有效:
Have you tried doing with the default C standard IO method? This has worked perfectly for me in the past:
FILE *file = fopen("/debugging_private_data.txt", "w");
if(!file){
// log an error opening file
} else {
fprintf(file, "My value: %d\n", x);
fclose(file);
}
这将在root
目录中创建文件debugging_private_data.txt.如果您可以在此写信(具有root权限),则可以在我想写的任何地方写信.
This creates the file debugging_private_data.txt at the root
directory. If you can write there (have root permission), you can write anywhere I guess.
这篇关于将文件写入越狱电话的根目录中,允许吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!