博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
An Android APK is really a zip file
阅读量:5158 次
发布时间:2019-06-13

本文共 2442 字,大约阅读时间需要 8 分钟。

An Android APK is really a zip file. The files in the resource directory are inside the APK file, therefore they are compressed within a zip file. The Lua io API such as io.open() is unable to open/extract files inside a zip file, thus it cannot open files within an APK. This is true of the io API on all platforms (Mac, Windows, iOS, and Android).

Now, the reason that the Lua io API can access resource files from an iOS package is because it is NOT a compressed file. The iOS package file contains its own directory structure which you can get an absolute path to its contained files that are accessible in the C language, which is what the Lua runtime is written in.

So, this presents an interesting problem with Android APKs. The C/C++ side of Corona and the Lua runtime are unable to access resource files within the APK because it is really a zip file. We have to access these files differently than how we do it compared to files outside of the APK. We do access these files via special Android function calls on the Java side. We've set up our Ansca made Corona APIs to be able to identify if it is a file within the APK or outside of the APK and open it seamlessly for you. However, the Lua "io" API was not made by Ansca but by the developers of Lua, so it has no understanding of what an APK is and how to access its contained files. So I hope this makes the problem clear to you.

That said, we've implemented some special handling. Calling system.pathForFile() on certain file types will cause Corona to automatically extract that file and copy it to an outside directory. It's a hack, not a good solution because it is wasteful on storage space, but it allows Lua io APIs to access certain file types.

system.pathForFile() will auto-extract all file types EXCEPT the following:

- *.html
- *.htm
- *.3gp
- *.m4v
- *.mp4
- *.png
- *.jpg
- *.ttf

This means that the above file types cannot be accessed by Lua io API. All other files will be automatically extracted when calling system.pathForFile() first. This is also why you can't access your HTML file. The reason that the HTML file is not auto-extracted is because typically images are linked to it as well so Corona would have to auto-extract image files too to make the web page appear correctly... but we definitely don't want to do this because images typically take a huge amount of space on storage.

转载于:https://www.cnblogs.com/superchao8/archive/2012/04/23/2466101.html

你可能感兴趣的文章
[Java] Java record
查看>>
jQuery - 控制元素显示、隐藏、切换、滑动的方法
查看>>
postgresql学习文档
查看>>
Struts2返回JSON数据的具体应用范例
查看>>
js深度克隆对象、数组
查看>>
socket阻塞与非阻塞,同步与异步
查看>>
团队工作第二天
查看>>
System类
查看>>
tableView
查看>>
Happy Great BG-卡精度
查看>>
Xamarin Visual Studio不识别JDK路径
查看>>
菜鸟“抄程序”之道
查看>>
Ubuntu下关闭防火墙
查看>>
TCP/IP 邮件的原理
查看>>
原型设计工具
查看>>
windows下的C++ socket服务器(4)
查看>>
css3 2d转换3d转换以及动画的知识点汇总
查看>>
【Java】使用Eclipse进行远程调试,Linux下开启远程调试
查看>>
对Vue为什么不支持IE8的解释之一
查看>>
计算机改名导致数据库链接的诡异问题
查看>>