Skip to main content

ZIP File Support

Please note these forums are being decommissioned and use the new and improved forums at
3 replies [Last post]
Joined: 2010-06-17

Imagine an application is loaded from a ZIP file:

 svc.0.service_id=0x13579 </code>
[prettify] svc.0.auto_select=true Test App transport.0=ic transport.0.service=0x13579 transport.0.url= app.8.application_identifier=0x101caffe7fff app.8.application_control_code=AUTOSTART app.8.visibility=VISIBLE app.8.priority=210 app.8.application_name=ZipTest app.8.base_directory=/ app.8.initial_class_name=com.zippy.ziptest.ZIPXlet app.8.args.0=def_zip_app=true app.8.args.1=launcher_app_id=0x17001 <code> app.8.service=0x13579 [/prettify]
What I would like to do is for the ZIP application be able to query its own contents, as if it were a mounted file system.
Now, when the app is downloaded, I see this in the trace log:
20110324 17:23:46.777 DEBUG    RI.Stack- 33421 [pool-3] DEBUG application.AppContext - autoload() 101caffe7fff
20110324 17:23:46.809 DEBUG    RI.Stack- 33455 [pool-3] DEBUG ManagerManager - getInstance: calling class
20110324 17:23:46.824 DEBUG    RI.Stack- 33464 [pool-3] DEBUG download.DownloadToStorage - Created instance
20110324 17:23:46.824 DEBUG    RI.Stack- 33468 [pool-3] DEBUG application.AppContext - locateInStorage(101caffe7fff,0)...
20110324 17:23:46.824 DEBUG    RI.Stack- 33470 [pool-3] DEBUG application.AppContext - App not found in storage
20110324 17:23:46.824 DEBUG    RI.Stack- 33472 [pool-3] DEBUG application.AppContext - Found tp = IC[,]
20110324 17:23:46.824 DEBUG    RI.Stack- 33474 [pool-3] DEBUG application.AppContext - ***** App Entry is for Http *****
20110324 17:23:46.824 DEBUG    RI.Stack- 33476 [pool-3] DEBUG application.AppContext - interaction channel URL: IC[,]
20110324 17:23:46.840 DEBUG    RI.Stack- 33479 [pool-3] DEBUG application.AppContext - zip's file name is  zip's base url is
20110324 17:23:46.840 DEBUG    RI.Stack- 33486 [pool-3] DEBUG http.HttpMount - HttpMount() -
20110324 17:23:46.855 DEBUG    RI.Stack- 33501 [pool-3] DEBUG http.HttpFileSys - target= mountPoint= /http0/
20110324 17:23:46.855 DEBUG    RI.Stack- 33505 [pool-3] DEBUG filesys.FileManagerImpl - register filesys org.cablelabs.impl.manager.filesys.AuthFileSys@6e3de8cd for path /http0
20110324 17:23:46.887 DEBUG    RI.Stack- 33538 [pool-3] DEBUG zip.ZipMount - Looking for zip hashfiles in /http0
20110324 17:23:46.918 DEBUG    RI.Stack- 33558 [Thread-7] DEBUG security.Policy - getPermissions((file:/syscwd/sys/support.jar &lt;no certificates&gt;))
20110324 17:23:46.934 DEBUG    RI.Stack- 33579 [pool-3] DEBUG zip.ZipMount - Hashfiles not found outside zip.  Authenticating inside.
20110324 17:23:46.996 DEBUG    RI.Stack- 33639 [pool-3] DEBUG zip.ZipMount$ZipFileSysMounter - mount() - zipFile=/http0/
<strong>20110324 17:23:46.996 DEBUG    RI.Stack- 33643 [pool-3] DEBUG zip.ZipMount$ZipFileSysMounter - mount() - mountPoint= /zipi0</strong>
20110324 17:23:47.043 DEBUG    RI.Stack- 33681 [pool-3] DEBUG http.HttpFileSys - HttpFileSys.getFileDataPriv() -- /http0/ -- Content length = 1153718
20110324 17:23:47.168 DEBUG    RI.Stack- 33806 [pool-3] DEBUG zip.ZipFileSys - zipfile has
20110324 17:23:47.168 DEBUG    RI.Stack- 33818 [pool-3] DEBUG zip.ZipFileSys - zipfile has com/zippy/

It is the bold line that interests me: can I query that mount point like a normal file system: e.g.

File fd = new File(&quot;/zipi0/&quot;);
if (fd.isDirertory()

Also is the file system added to the Root filesystems so

would return [as one of its values] "/zipi0/"
Also, how can the app tell where its mount point is? Would it have to look in the app table for itself, get the transport and then query the filesystem to get the actaul mountpoint? This is in case there are multiple apps running and therefore /zipi0/ and [say] /zipi1/ would exist. The app would not be able to tell from where it ran.
Basically, what I want to do is have an app, either on an HTTP server, or preferably on a USB drive, that I can load from a ZIP file and then get all of the support files for that app - not just resource files - from the same ZIP file.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-07-03

The absolute path of an application's filesystem is implementation-dependent. However, an application can access this path by using a relative pathname in operations. Relative paths will access files relative to the baseDirectory (as signaled in the X/AIT) of the application. Is that enough information to answer your question?

Joined: 2010-06-17

But what would the base directory be in the above example?

/zipi0/ -- ?

As this is a dynamically changing value. Or can we use the url of the source?
What about using a USB memory stick mounted on, say, /dev/usb0. At this point the transport and location of the ZIP file would be

Would this again become

How do we know, prior to mounting the file system, what the base directory is?

Joined: 2008-07-03

I am using the term "base directory" in the strict OCAP sense (the field in the X/AIT). It is the directory relative to the transport protocol associated with the application. This "base directory" becomes the root directory for your application and the highest directory in that filesystem that your application can access.

Transport Protocol URL:
XAIT base_directory: dir3/dir4
Application root directory is:

The RI maps this application directory to a private internal mount point. In the case of your example, the mount point is:


As an application, you do not need to know what /zipi0 is. All you need to know is that all access above your application root directory is strictly forbidden. To access all other files in your application subtree, use a relative file path in* operations and that path will be relative to your application root directory.

In the case of a transport protocol URL that specifies a zip file, the base_directory field of your XAIT entry specifies a subdirectory relative to the root of the filesystem contained within the zip file.