Accessing a user's home directory

Hello,

I'm building a xulrunner application, and I have a need to store/
access files in a user's home directory; that is, the application may
be installed system-wide, but each user will be able to store/access
their own files with it.

How do I reference the user's home directory in a platform-agnostic
way?

Thanks!

John

0
john
2/5/2007 11:46:53 PM
mozilla.dev.tech.xul 2282 articles. 0 followers. Post Follow

3 Replies
438 Views

Similar Articles

[PageSpeed] 2

On 06/02/2007 00:46 (CET), john wrote:
> Hello,
> 
> I'm building a xulrunner application, and I have a need to store/
> access files in a user's home directory; that is, the application may
> be installed system-wide, but each user will be able to store/access
> their own files with it.
> 
> How do I reference the user's home directory in a platform-agnostic
> way?

var dirService = 
Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
var homeDirFile = dirService.get("Home", Components.interfaces.nsIFile); 
// returns an nsIFile object
var homeDir = homeDirFile.path;

-- 
Brian King
www.mozdev.org - free project hosting for the Mozilla community

0
Brian
2/6/2007 11:02:05 PM
On Feb 6, 3:02 pm, Brian King <b...@mozdev.org> wrote:
> On 06/02/2007 00:46 (CET), john wrote:
>
> > Hello,
>
> > I'm building a xulrunner application, and I have a need to store/
> > access files in a user's home directory; that is, the application may
> > be installed system-wide, but each user will be able to store/access
> > their own files with it.
>
> > How do I reference the user's home directory in a platform-agnostic
> > way?
>
> var dirService =
> Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
> var homeDirFile = dirService.get("Home", Components.interfaces.nsIFile);
> // returns an nsIFile object
> var homeDir = homeDirFile.path;
>
> --
> Brian Kingwww.mozdev.org- free project hosting for the Mozilla community

Hi There,

Thanks again for your response.  I have a follow-up question.  The app
I'm developing can live anywhere on the filesystem.  Ultimately, it
will be run via xulrunner, but during the development, I have put a
manifest file in the firefox chrome directory, and access it in the
browser as "chrome://foo/content/foo.xul".  My question is, given my
files might be in "c:\foo\" or perhaps "/home/john/foo", how can I get
the path to, say, foo?  I've tried all the jslib options, but they're
all browser-specific.

I've also tried the "getInstallLocation" method of
Components.interfaces.nsIExtensionManager, no luck there either.

Sorry for the verbosity - needed to provide context.

John

0
john
2/9/2007 9:19:58 PM
> Hi There,
>
> Thanks again for your response.  I have a follow-up question.  The app
> I'm developing can live anywhere on the filesystem.  Ultimately, it
> will be run via xulrunner, but during the development, I have put a
> manifest file in the firefox chrome directory, and access it in the
> browser as "chrome://foo/content/foo.xul".  My question is, given my
> files might be in "c:\foo\" or perhaps "/home/john/foo", how can I get
> the path to, say, foo?  I've tried all the jslib options, but they're
> all browser-specific.
>
> I've also tried the "getInstallLocation" method of
> Components.interfaces.nsIExtensionManager, no luck there either.
>
> Sorry for the verbosity - needed to provide context.
>
> John

Looks like I hit "send" too soon - jslib has a fileutil "chromeToPath"
which seems to do the trick!

John

0
john
2/9/2007 9:31:14 PM
Reply:

Similar Artilces:

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

Automatically make directories in user's home directory
How can I do this? Basically I want the equivalent of /etc/skel on linux to happen on my netware box. Specifically what I am wanting is a Favorites folder and a Desktop folder made in their home directory so I can use folder redirection to point those portions of their profiles to there. I do not want to hand make these folders in every new user's home directory. Thanks! Adam I see that those mirectories are made automatically. Although I would still be interested to know if there is some way to do an equivalent to /etc/skel because I can see that being usefull. T...

changes made from one user's webpart's page, effects all user's
 I am just doing this offline right now in Visual Web Developer Express 2008I created the login inonce in the memberpage area, people can modify their webpart page. I created several users to test this out.  I loaded it in a browser.When I make changes as logged in user "A" .  Then logout and login as user "B", user "B,s" webpart page has been changed to user "A".This goes true for whomever I log in as.  It changes for everyone.Is there something specific I need to do in order to get everyone's changes to be unique for them...

access user's local machine's info
Hi, Is that possible we can implement something in ASP.NET to access user's local machine's info, such as MAC# or Hard Drive #? Thanks. Chia Nope. Or, more specifically, I hope not. This would be a major, huge security breach. The best you could do is to embed an ActiveX or .NET component in the page, convince the user to install it, and get the info that way. This would only be reasonable in an intranet situation. But you'd have to install it independently of the ASP.NET page before you could use it. DonDon Kiely, MCP, MCSDIn the Last Frontier, Interior AlaskaPlease post ...

Install into user's HOME directory?
On page 86 of the IDM 3.01 install guide for User App, it says that you shouldn't login as ROOT to install, but that the install directory goes into the user's home directory in the /novell/idm directory. Now, why would you want to install something into a specific user's home directory for server-based software that needs writable access? Is there a better place to install the User App to? (/usr or something)? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Why does the software need writeable access? Except for the logs (and temporary files for JBoss), perh...

Help! I cannot access the DataGrid's ItemTemplate's LinkButton's Text Atrribute 's Value!!!!!!!!!!!
I write a datagrid's ItemDataBound method as follows:   private void dgTable_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)  {   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)   {    if(!isRole("Manager"))    {     LinkButton tmp = (LinkButton)e.Item.FindControl("lbPassed");     if(tmp.Text == "Passed")     {      ((LinkBu...

Securing or encrypting a user's home directory
Does anyone have any experience or recommendations with products that could encrypt a user's home directory entirely, where by they would unlock it upon logging into the tree? Maybe something that integrates into the Novell client. We use NetWare 6.5 file servers but are headed towards OES2 Thanks! -- dsmi87dgf ------------------------------------------------------------------------ ...

Can you move User's Home Directories by Hand?
I have a need to move about 200 user's home directories from a NW5.0 server to and NW6.5 server. I was going to do it this weekend. I was searching around on Deja.com and it seems a lot of people pay a bundle to get a utility to do it. Is there anything wrong with just copying the directories from one server to another and then editing the user objects through console1 and changing it to the new loc? Obviously it will take some time, but is there any actual reason or danger invovled in just doing it this way? Thanks for your help. Hopefully, I can get it done this wee...

NXserver, No .Xauthority file in user's home directory
Been trying to get nxserver running on 11.2 i386 at location A and keep getting an error on connecting from client at location B. Code: -------------------- NX> 203 NXSSH running with pid: 6439 NX> 285 Enabling check on switch command NX> 285 Enabling skip of SSH config files NX> 285 Setting the preferred NX options NX> 200 Connected to address: 72.4.183.23 on port: 22 NX> 202 Authenticating user: nx NX> 208 Using auth method: publickey /usr/bin/xauth: /usr/NX/home/nx/.Xauthority not writable, changes will be ignored HELLO NXSERVE...

ifolder 2.1 and user's Home directory
Is it possible to have ifolder point to the user's H:drive? I think it would be much easier to maintain. Also easier on the users they would not have to track 2 sets of files. I know this was not available on previous versions. Can someone let me know if its been added or how to do it? Thank you. , > Is it possible to have ifolder point to the user's H:drive? I think it > would be much easier to maintain. Also easier on the users they would not > have to track 2 sets of files. I know this was not available on previous > versions. Can someone let me know i...

Moving user's home directories to NSS partition
Hi all! Can I move/change my user's home directories to a NSS partition? I need to setup the user home directory when create user account, using \\server\volume at the user home directory field, in iManager. Can I do this? Anybody here has some information about? Tks, Best regards... Alan Cota. On Tue, 01 Aug 2006 00:17:54 +0000, Alan Cota wrote: Sure any user residing in eDirectory can have their home directory residing on an NSS volume, no problem. Just treat it the same way as if the volume had resided on a NetWare server. -- ___________________________...

Re-associate User ID's with Home Directories
Hello all, When our main server crashed, we had to restore from backup. All the volumes containing our users files were restored back into their original location and server was given the same name, but our users have lost the association between their account and home directory. We started to manually go through and re-associate the directories with the users on ConsoleOne, but this would take days. Is there a tool that could perform a batch operation for such a task? The User ID is the same as the folder name. Thanks in advance, Tim Williams If it were me, I'd...

How to limit a user's access privilige to certain directories?
Hello, friends, We use Form authentication in our asp.net app (1.1). We require a user to login in first. It worked fine. However, we now have another problem: Once a user is logged in, he/she can virtually visit any web pages in different directories, including the /Admin/ModifyUserInfo.aspx! How can I limit general user's access privilige to those directories, and only allow certain users to have this privilige? Any reference papers or sample source code? Thanks a lot I don't know if this works in ASPNET 1.1, but if you are now in ASPNET 2.0, try using roles for users (one role for "...

User's home directory saved in Samba server not locally
Hi guys, Continuing with my assigned task of migrating the company's PCs to GNU/Linux ('openSUSE as server for GNU/Linux clients' (http://tinyurl.com/5sqzjl7)) I managed to set up a DC with roaming profiles for the few remaining Windows users, user validation and login for the openSUSE boxes and a few network shares with different rights. I know there are no roaming profiles for GNU/Linux and I can live with that but I would like to specify wich users/groups would have their home directories saved locally (notebook users) and which will save them on the Samba server...

Web resources about - Accessing a user's home directory - mozilla.dev.tech.xul

Resources last updated: 11/21/2015 6:09:15 AM