Skip to main content

ZIP File Support

3 replies [Last post]
howardteece
Offline
Joined: 2010-06-17
Points: 0

Imagine an application is loaded from a ZIP file:

 svc.0.service_id=0x13579 </code>
[prettify] svc.0.auto_select=true
svc.0.name=My Test App transport.0=ic transport.0.service=0x13579 transport.0.url=http://172.20.101.159/zippy.zip 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 org.cablelabs.impl.manager.download.DownloadToStorage.getInstance
20110324 17:23:46.824 DEBUG    RI.Stack- 33464 [pool-3] DEBUG download.DownloadToStorage - Created instance org.cablelabs.impl.manager.download.DownloadToStorage@80d79420
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[http://172.20.101.159/zippy.zip,]
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[http://172.20.101.159/zippy.zip,]
20110324 17:23:46.840 DEBUG    RI.Stack- 33479 [pool-3] DEBUG application.AppContext - zip's file name is zippy.zip.  zip's base url is http://172.20.101.159/
20110324 17:23:46.840 DEBUG    RI.Stack- 33486 [pool-3] DEBUG http.HttpMount - HttpMount() - http://172.20.101.159/
20110324 17:23:46.855 DEBUG    RI.Stack- 33501 [pool-3] DEBUG http.HttpFileSys - target=http://172.20.101.159/. 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/zippy.zip
<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/zippy.zip -- Content length = 1153718
20110324 17:23:47.168 DEBUG    RI.Stack- 33806 [pool-3] DEBUG zip.ZipFileSys - zipfile has ocap.storage.101caffe.7fff
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()
   fd.listFiles();

Also is the file system added to the Root filesystems so
File.listRoots()

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.
Thanks.

Reply viewing options

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

The absolute path of an application's filesystem is implementation-dependent. However, an application can access this path by using a relative pathname in java.io.File 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?

howardteece
Offline
Joined: 2010-06-17
Points: 0

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
/dev/usb0/zippy.zip

Would this again become
/zipi0/

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

greg80303
Offline
Joined: 2008-07-03
Points: 0

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: http://myserver.mydomain.org/dir1/dir2
XAIT base_directory: dir3/dir4
Application root directory is: http://myserver.mydomain.org/dir1/dir2/dir3/dir4

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

/zipi0/

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 java.io.* 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.