zoukankan      html  css  js  c++  java
  • An Android APK is really a zip file

    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.

  • 相关阅读:
    被老板批评“公司离开谁都照转,谁的工作干不好谁走人”,你会立马辞职吗?
    开课啦 dubbo-go 微服务升级实战
    如何通过 Serverless 提高 Java 微服务治理效率?
    Alluxio 助力 Kubernetes,加速云端深度学习
    收藏!这些 IDE 使用技巧,你都知道吗
    基于 Wasm 和 ORAS 简化扩展服务网格功能
    基于 KubeVela 与 Kubernetes 打造“无限能力”的开放 PaaS
    Kubernetes 稳定性保障手册 -- 日志专题
    Kubernetes 稳定性保障手册 -- 极简版
    Serverless 如何在阿里巴巴实现规模化落地?
  • 原文地址:https://www.cnblogs.com/superchao8/p/2466101.html
Copyright © 2011-2022 走看看