对phonegap和IOS感到困惑,需要从“www”获取文件来自“插件”的路径文件夹
我在 IOS 上使用phonegap。我创建了一个插件来解压缩文件。但现在我正在尝试测试它,但它无法获得我假设的正确文件路径。现在这里是我从 ZipArchive 插件类中调用解压缩方法的片段:
NSLog(@"Trying to unzip file");
if([ za UnzipOpenFile:@"../www/data/test.zip"]){
NSLog(@"UnzipOpenFile passed");
}
phonegap 的结构是这样的
- ProjectName
- www
- data
- test.zip
- Plugin
- ZipArchive.m //where the above snippet lies
我想我不能使用这样的相对路径,因为在最终产品中,当编译和在模拟器上测试,路径可能会有所不同。如何从 ZipArchive.m 访问 www/data 文件夹?谢谢。
I am using phonegap for IOS. I created a Plugin to unzip files. But now I am trying to test it but its unable to get the correct file path I'm assuming. Right now here is the snippet of where I cal the unzip method, from my ZipArchive plugin class:
NSLog(@"Trying to unzip file");
if([ za UnzipOpenFile:@"../www/data/test.zip"]){
NSLog(@"UnzipOpenFile passed");
}
The structure of the phonegap is something like this
- ProjectName
- www
- data
- test.zip
- Plugin
- ZipArchive.m //where the above snippet lies
I am thinking I can't use relative path like that because in the end product, when compiled and testing on simulator, the path will probably be different. How would I access the www/data folder from ZipArchive.m? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过以下方式获取
www
文件夹中内容的路径:您打算解压缩到哪里?我非常确定在真实设备上运行时资源路径是只读的。但文档路径和 tmp 文件夹是可写的。
http://developer.apple.com/库/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/RuntimeEnvironment/RuntimeEnvironment.html
You should be able to get a path to things in the
www
folder with:Where are you planing to unzip to? Im quite sure the resource path is read-only when running on a real device. But the documents path and a tmp folder is writeable.
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/RuntimeEnvironment/RuntimeEnvironment.html