write the files in root directory in jailbreak phone,permitted?

吃可爱长大的小学妹 提交于 2019-12-12 05:39:33

问题


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?


回答1:


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);
}

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.



来源:https://stackoverflow.com/questions/20113402/write-the-files-in-root-directory-in-jailbreak-phone-permitted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!