在 iOS 设备上编写和访问应用程序文件
我有一个程序可以生成自己的 Wireshark pcap 文件(如果您以前没有使用过它,则可以算是网络日志)。我的应用程序使用 ANSI-C 代码来执行此操作。 在 Android 和 Windows 中,我只需使用“fopen”和“fwrite”等将文件写入光盘。
这在 iOS 上如何运作? 我将提供给 fopen 的文件路径是什么?例如,在 Android 中我使用“/sdcard”或类似的,这里是什么? 之后如何从我的 iOS 设备中实际提取该文件?
编辑:我需要明确使用 ANSI-C;所有的编写都是在我的 iOS 应用程序中使用的 C 库中完成的
I have a program which generates its own Wireshark pcap-file (sort of a network log if you havnt used it before). My app uses ANSI-C code to do this.
In Android and Windows I simply use 'fopen' and 'fwrite' etc to write file to disc.
How does this work on iOS?
What is the filepath I will supply to fopen? For example in Android I use "/sdcard" or similiar, what is it here?
How do I actually extract the file afterwards from my iOS device?
EDIT: I need to use ANSI-C explicitly; all the writing is done in C libraries used in my iOS app
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您完全可以使用
fopen
(我在跨平台代码中使用它)。但是,您确实想要使用[documentPath fileSystemRepresentation]
。You can totally use
fopen
(I use it in cross-platform code). You do however want to use[documentPath fileSystemRepresentation]
.在 iOS 中,可以使用以下代码找到文档目录路径:
目标编写方法可能是:
使用“C”方法(例如 fopen)获取基于字符的字符串:
其中
encoding
可能是NSUTF8StringEncoding
或其他支持的编码。In iOS the document directory path can be found with this code:
The Objective writing method might be:
To use "C" methods such as fopen get the char based string:
where
encoding
might beNSUTF8StringEncoding
or another supported encoding.