<terminal>
/**
*    @Author: Arash Karimzadeh
*    @Email: me@arashkarimzadeh.com
*    @Desciption: Here, I post some of my recent
*    researches. Also you can see my code projects.
*/  
Ajax C # Chrome CMS dateNet Design Patterns includeMany JavaScript jBind Joomla jQuery Plugin rails ror RubyOnRails SQLite xul

+ All tags

Content View Hits : 313123
Bookmark and Share
Accessing Directories and Location in XUL (by JavaScript) PDF Print E-mail
Written by Arash Karimzadeh   
Sunday, 28 June 2009 06:01

Here we will see how we can access a specific directory in XUL application by javascript. There is a service provided by mozilla called "@mozilla.org/file/directory_service".

by using following code you can access the location of Profile Directory of your computer:

 

  1. var file = Components.classes["@mozilla.org/file/directory_service;1"]
  2.                      .getService(Components.interfaces.nsIProperties)
  3.                      .get("ProfD", Components.interfaces.nsIFile);
 

The "ProfD" means Profile Directory.

You can replace it with other options such as:

Desk
Desktop directory (e.g. ~/Desktop on Linux, C:\Documents and Settings\username\Desktop on Windows)
AChrom%installation%/chrome  (e.g. myApp/chrome/)
UChrm
%profile%/chrome
ProfD
profile directory
DefProfRt
user
DefRt
%installation%/defaults (e.g. myApp/defaults/)
PrfDef%installation%/defaults/pref (e.g. myApp/xulrunner/defaults/pref)
ProfDefNoLoc%installation%/defaults/profile (e.g. myApp/xulrunner/defaults/profile)
APlugns%installation%/plugins
ComsD%installation%/components
CurProcDinstallation (usually)
HomeOS root (e.g., C:\Documents and Settings\username on Windows or /root on Linux)
TmpDOS tmp (e.g., /tmp)
ProfLDLocal Settings on windows; where the network cache and fastload files are stored
resource:appapplication directory in a XULRunner app
ProgsUser start menu programs directory (e.g., C:\Documents and Settings\username\Start Menu\Programs)

 *The above examples are for an application called myApp. You can create this project by reading this article.

You can find more other options at xpcom/io/nsAppDirectoryServiceDefs.h and xpcom/io/nsDirectoryServiceDefs.h.

Tags: Chrome | JavaScript | xul

Last Updated on Sunday, 28 June 2009 09:18
 
</terminal>