[Jslib] File permissions

Pete Collins pete at mozdevgroup.com
Thu Feb 17 09:35:18 EST 2005



Jean-Denis Girard wrote:

> Hi,
>
> I'm trying to extract an exe file from the chrome JAR archive, to a 
> place where it can be spawned by Firefox.
> After much difficulties and googling, I came up with the following 
> piece of code, which does mostly what I want:


Why is the exe file in the jar archive?

You can use xpinstall to install it wherever you want ...

--pete

>
> var dir = new Dir( du.getMozUserHomeDir() );
> var ios = 
> jslibGetService("@mozilla.org/network/io-service;1","nsIIOService");
> var uri = 
> ios.newURI("chrome://mozphone/content/network_client",null,null);
> var channel = ios.newChannelFromURI(uri);
> var is = 
> jslibCreateInstance("@mozilla.org/binaryinputstream;1","nsIBinaryInputStream"); 
>
> is.setInputStream(channel.open());
> var exe_file = fu.append( dir.path, 'network_client');
> var exe = new File( exe_file );
> exe.open('wb', 755);
> exe.write(is.readByteArray(is.available()));
> alert( exe.permissions );
> exe.close();
> fu.spawn( exe_file );
>
> My problem is that file permission remains 0644, so execution 
> obviously fails. Reading file.js, my understanding is that file 
> permissions are allways default, as file is created:
> rv = this.mFileInst.create(JS_FILE_FILE_TYPE, JS_FILE_DEFAULT_PERMS);
>
> Any help would be appreciated.
>
>
> Thanks,
> Jean-Denis Girard
>
> SysNux                  Systèmes Linux en Polynésie française
> http://www.sysnux.pf/   Tél: +689 483 527 / GSM: +689 797 527
> _______________________________________________
> Jslib mailing list
> Jslib at mozdev.org
> http://mozdev.org/mailman/listinfo/jslib
>
>

-- 
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions 




More information about the Jslib mailing list