Visit Mozilla.org

nsILocalFile

From MDC

« XPCOM API Reference

Contents

[edit] Summary

The nsILocalFile interface represents a file or directory location in a platform-independent manner that is accessible on the local filesystem. It extends nsIFile.

 #include "nsILocalFile.h"
  
 [scriptable, uuid=(aa610f20-a889-11d3-8c81-000064657374)]
 interface nsILocalFile : nsIFile { ... };

[edit] Methods

initWithPath
This method is used for setting the full path that this nsILocalFile references.
initWithNativePath
This method is used for setting the full path that this nsILocalFile references. [native character encoding variant]
initWithFile
This method is used for initializing a nsILocalFile from another nsILocalFile.
openNSPRFileDesc
This method is used for opening the file corresponding to this nsILocalFile.
openANSIFileDesc
This method is used for opening the file corresponding to this nsILocalFile.
load
This method is used for opening the dynamically linked library corresponding to this nsILocalFile.
appendRelativePath
This method is used for appending a relative path to the current nsILocalFile.
appendRelativeNativePath
This method is used for appending a relative path to the current nsILocalFile. [native character encoding variant]
reveal
This method requests that the operating system reveal this nsILocalFile to the user. Not supported on some platforms.
launch
This method requests that the operating system attempt to open this nsILocalFile. Not supported on some platforms.
getRelativeDescriptor
This method returns a cross-platform representation of a relative file path.
setRelativeDescriptor
This method initializes a nsILocalFile from a relative descriptor obtained from getRelativeDescriptor.

[edit] Attributes

followLinks
This attribute determines whether or not the nsILocalFile will automatically resolve symbolic links.
diskSpaceAvailable
This attribute exposes the amount of available disk space on the disk volume containing this nsILocalFile.
persistentDescriptor
This attribute exposes a platform-specific, unique string representation of this nsILocalFile.

[edit] Remarks

The methods initWithNativePath and appendRelativeNativePath take string valued parameters that are encoded using the native character encoding. That means, you cannot deal with files whose name contain characters outside the default code page on Windows even though Windows 2000 or later has no problem with them. Therefore, never use these functions unless you are absolutely sure that the path passed to them is always ASCII-only. See nsIFile for more information on the native character encoding.

launch and reveal are currently (as of 2007/03/14, FX3.0, Gecko 1.9) only implemented for Windows, MacOSX, BeOS and OS/2. On *nix-ish systems like Linux, BSDs, Solaris or similar neither of both functions will perform anything but instead immediately return NS_ERROR_FAILURE. See bug 67001 for further information.
To cover these systems as well you might want to consider the work-around from Firefox Download Manager. For some "inspiration" see: http://mxr.mozilla.org/seamonkey/source/toolkit/mozapps/downloads/content/downloads.js

[edit] History

This interface was frozen for Mozilla 1.0. See bug 129279 for details.