You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


TOC PREV NEXT INDEX

Embedding Gecko API


nsILocalFile


This interface adds methods to nsIFile that are particular to a file that is accessible via the local file system. It follows the same string conventions as nsIFile.

Methods
initWithPath
initWithNativePath

Initializes the nsILocalFile object. Any internal state information will be reset.

Note: This function has a known bug on the Macintosh and other OSes which do not represent file locations as paths. If you do use this function, be very aware of this problem.

Syntax:

void nsIFile::initWithPath(in AString filePath) 
[noscript] void nsILocalFile::initWithNativePath(
	in ACString filePath) 

Parameters:

filePath: A string which specifies a full file path to a location. Relative paths will be treated as an error (NS_ERROR_FILE_UNRECOGNIZED_PATH). For initWithNativePath, the filePath must be in the native filesystem charset.

nsresult:

NS_OK if successful.
initWithFile

Initializes this object with another file.

Syntax:

void nsILocalFile::initWithFile(in nsILocalFile aFile) 

Parameters:

aFile: The file to which this becomes equivalent.

nsresult:

NS_OK if successful.
openNSPRFileDesc

Opens the NSPR file descriptor. This method is not scriptable.

Syntax:

[noscript]PRFileDescStar nsILocalFile::openNSPRFileDesc(
	in long flags, in long mode)  

Parameters:

flags: The appropriate flags.
mode: The appropriate mode.

Returns:

A pointer to the descriptor.
openANSIFileDesc

Opens the ANSI file descriptor. This method is not scriptable.

Syntax:

[noscript] FILE nsILocalFile::openANSIFileDesc(
	in string mode) 

Parameters:

mode: The appropriate mode.

Returns:

A pointer to the file.
load

Loads this file (a library). This method is not scriptable.

Syntax:

[noscript] PRLibraryStar nsILocalFile::load() 

Parameters:

None.

Returns:

A pointer to the library.
appendRelativePath
appendRelativeNativePath

Appends a relative path to the current path of the nsILocalFile object.

Syntax:

void nsILocalFile::appendRelativePath(
	in AString relativeFilePath) 
[noscript]void nsILocalFile::appendRelativeNativePath(
	in ACString relativeFilePath) 

Parameters:

relativeFilePath: The relative file path. It is a native relative path. For security reasons, it cannot contain .. or start with a directory separator. For the appendRelativeNativePath method, relativeFilePath must be in the native filesystem charset.

nsresult:

NS_OK if successful.
reveal

Asks the operating system to open the folder which contains this file or folder. This routine only works on platforms which support the ability to open a folder.

Syntax:

void nsILocalFile::reveal() 

Parameters:

None.

nsresult:

NS_OK if successful.
launch

Asks the operating system to attempt to open the file. This really just simulates "double clicking" the file on your platform and thus only works on platforms which support this functionality.

Syntax:

void nsILocalFile::launch() 

Parameters:

None.

nsresult:

NS_OK if successful.
getRelativeDescriptor

Gets a relative file path in an opaque, XP format. It is therefore not a native path.

Note: The character set of the string returned from this function is undefined.

DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!

Syntax:

ACString nsILocalFile::getRelativeDescriptor(
	in nsILocalFile fromFile) 

Parameters:

fromFile: The file from which the descriptor is relative.

Returns:

The descriptor.
setRelativeDescriptor

Initializes the file to the location relative to fromFile using a string returned by getRelativeDescriptor.

Syntax:

void nsILocalFile::setRelativeDescriptor(
	in nsILocalFile fromFile, in ACString relativeDesc) 

Parameters:

fromFile: The file to which the descriptor is relative.
relativeDesc: The relative descriptor obtained from getRelativeDescriptor.

nsresult:

NS_OK if successful.
Attributes
attribute PRBool nsILocalFile::followLinks

Gets and sets whether the nsLocalFile will auto resolve symbolic links. By default, this value will be FALSE on all non Unix systems. On Unix, this attribute is effectively a no-op.

Be aware that changing this attribute from TRUE to FALSE after the nsILocalFile has been initialized may lead to errors. This could happen if there were resolved symlink in the initialized path. For example if you had /a/b/c where |b| was a symlink, and you change this attribute to FALSE, the next usage would most likely fail.

readonly attribute PRInt64 nsILocalFile::diskSpaceAvailable

Gets available disk space.

attribute ACString nsILocalFile::persistentDescriptor

Gets and sets a null-terminated string which will specify the file in a persistent manner for disk storage.

Note: The character set of this attribute is undefined.

DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!


Written by:Ellen Evans | Comments, questions, complaints? Bug 143387
TOC PREV NEXT INDEX