Readonly
canonicalReadonly
creationThe creation time of file in milliseconds from midnight, January 1, 1970 GMT, if available.
This attribute is only implemented on Windows and macOS. Accessing this on another platform will this will throw NS_ERROR_NOT_IMPLEMENTED.
Readonly
creationReadonly
directoryReturns an enumeration of the elements in a directory. Each element in the enumeration is an nsIFile.
NS_ERROR_FILE_NOT_DIRECTORY if the current nsIFile does not specify a directory.
Readonly
diskReadonly
diskReadonly
displayThe leaf name as displayed in OS-provided file pickers and similar UI.
On Windows and macOS, 'real' leaf names of some directories can be
in English, but the OS will show a different, translated name to users
using a different locale. So folders like "Downloads", "Desktop" and
"Documents" might not normally appear to users with that (English) name,
but with an OS-localized translation. This API will return such a
translation if it exists, or the leafName if it doesn't.
On Linux, this will always be the same as leafName
.
WARNING! On the Mac, getting/setting the file size with nsIFile only deals with the size of the data fork. If you need to know the size of the combined data and resource forks use the GetFileSizeWithResFork() method defined on nsILocalFileMac.
Readonly
fileThe last accesss time of the file in milliseconds from midnight, January 1, 1970 GMT, if available.
File Times are to be in milliseconds from midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
Accessor to the leaf name of the file itself. For the |nativeLeafName| method, the nativeLeafName must be in the native filesystem charset.
Readonly
nativeReadonly
parentParent will be null when this is at the top of the volume.
Readonly
pathAttributes of nsIFile.
Accessor to a null terminated string which will specify the file in a persistent manner for disk storage.
The character set of this attribute is undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!
Get or set whether this file is marked read-only.
Throws NS_ERROR_FILE_INVALID_PATH for an invalid file. Throws NS_ERROR_FAILURE if the set or get fails.
Readonly
targettarget & path
Accessor to the string path. The native version of these strings are not guaranteed to be a usable path to pass to NSPR or the C stdlib. There are problems that affect platforms on which a path does not fully specify a file because two volumes can have the same name (e.g., mac). This is solved by holding "private", native data in the nsIFile implementation. This native data is lost when you convert to a string.
DO NOT PASS TO USE WITH NSPR OR STDLIB!
target Find out what the symlink points at. Will give error (NS_ERROR_FILE_INVALID_PATH) if not a symlink.
path Find out what the nsIFile points at.
Note that the ACString attributes are returned in the native filesystem charset.
Setting this to true will prepend the prefix "\?" to all parsed file paths which match ^[A-Za-z]:\.* (regex) syntax.
There are two known issues (and potentially more) which can be resolved by the prefix:
In the Windows API, the maximum length for a path is MAX_PATH in general. However, Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters.
A path component which ends with a dot is not allowed for Windows API.
If either of these issues are expected to be common in your code, you should set this flag to true. (You should probably not have to set this flag to true.)
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
append[Native]
This function is used for constructing a descendent of the current nsIFile.
A string which is intended to be a child node of the nsIFile. For security reasons, this cannot contain .. and cannot start with a directory separator. For the |appendNative| method, the node must be in the native filesystem charset.
appendRelative[Native]Path
Append a relative path to the current path of the nsIFile object.
relativeFilePath is a native relative path. For security reasons, this cannot contain .. and cannot start with a directory separator. For the |appendRelativeNativePath| method, the relativeFilePath must be in the native filesystem charset.
copyTo[Native]
This will copy this file to the specified newParentDir. If a newName is specified, the file will be renamed. If 'this' is not created we will return an error (NS_ERROR_FILE_NOT_FOUND).
copyTo may fail if the file already exists in the destination directory.
copyTo will NOT resolve aliases/shortcuts during the copy.
This param is the destination directory. If the newParentDir is null, copyTo() will use the parent directory of this file. If the newParentDir is not empty and is not a directory, an error will be returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For the |CopyToNative| method, the newName must be in the native filesystem charset.
This param allows you to specify a new name for the file to be copied. This param may be empty, in which case the current leaf name will be used.
copyToFollowingLinks[Native]
This function is identical to copyTo with the exception that, as the name implies, it follows symbolic links. The XP_UNIX implementation always follow symbolic links when copying. For the |CopyToFollowingLinks| method, the newName must be in the native filesystem charset.
create
This function will create a new file or directory in the file system. Any nodes that have not been created or resolved, will be. If the file or directory already exists create() will return NS_ERROR_FILE_ALREADY_EXISTS.
This specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above. If the type is unrecongnized, we will return an error (NS_ERROR_FILE_UNKNOWN_TYPE).
The unix style octal permissions. This may be ignored on systems that do not need to do permissions.
Optional; if set to true, we'll skip creating ancestor directories (and return an error instead).
createUnique
This function will create a new file or directory in the file system. Any nodes that have not been created or resolved, will be. If this file already exists, we try variations on the leaf name "suggestedName" until we find one that did not already exist.
If the search for nonexistent files takes too long (thousands of the variants already exist), we give up and return NS_ERROR_FILE_TOO_BIG.
This specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above. If the type is unrecongnized, we will return an error (NS_ERROR_FILE_UNKNOWN_TYPE).
The unix style octal permissions. This may be ignored on systems that do not need to do permissions.
getRelativeDescriptor
Returns a relative file path in an opaque, XP format. It is therefore not a native path.
The character set of the string returned from this function is undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!
the file from which the descriptor is relative. Throws if fromFile is null.
getRelativePath
Returns a relative file from 'fromFile' to this file as a UTF-8 string. Going up the directory tree is represented via "../". '/' is used as the path segment separator. This is not a native path, since it's UTF-8 encoded.
the file from which the path is relative. Throws if fromFile is null.
initWith[Native]Path
This function will initialize the nsIFile object. Any internal state information will be reset.
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.
launch
Ask the operating system to attempt to open the file. this really just simulates "double clicking" the file on your platform. This routine only works on platforms which support this functionality and is run async on Windows. This routine must be called on the main thread.
moveTo[Native]
A method to move this file or directory to newParentDir. If a newName is specified, the file or directory will be renamed. If 'this' is not created we will return an error (NS_ERROR_FILE_NOT_FOUND). If 'this' is a file, and the destination file already exists, moveTo will replace the old file. This object is updated to refer to the new file.
moveTo will NOT resolve aliases/shortcuts during the copy. moveTo will do the right thing and allow copies across volumes. moveTo will return an error (NS_ERROR_FILE_DIR_NOT_EMPTY) if 'this' is a directory and the destination directory is not empty. moveTo will return an error (NS_ERROR_FILE_ACCESS_DENIED) if 'this' is a directory and the destination directory is not writable.
This param is the destination directory. If the newParentDir is empty, moveTo() will rename the file within its current directory. If the newParentDir is not empty and does not name a directory, an error will be returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For the |moveToNative| method, the newName must be in the native filesystem charset.
This param allows you to specify a new name for the file to be moved. This param may be empty, in which case the current leaf name will be used.
moveToFollowingLinks[Native]
This function is identical to moveTo with the exception that, as the name implies, it follows symbolic links. The XP_UNIX implementation always follows symbolic links when moving. For the |MoveToFollowingLinks| method, the newName ust be in the native filesystem charset.
Return the result of PR_Open on the file. The caller is responsible for calling PR_Close on the result. On success, the returned PRFileDescr must be non-null.
the PR_Open flags from prio.h, plus optionally OS_READAHEAD or DELETE_ON_CLOSE. OS_READAHEAD is a hint to the OS that the file will be read sequentially with agressive readahead. DELETE_ON_CLOSE is unreliable on Windows and is deprecated. Instead use NS_OpenAnonymousTemporaryFile() to create a temporary file which will be deleted upon close.
Identical to nsIFile::openNSPRFileDesc except it also uses the FILE_SHARE_DELETE flag.
This will try to delete this file. The 'recursive' flag must be PR_TRUE to delete directories which are not empty.
If passed, 'removeCount' will be incremented by the total number of files and/or directories removed. Will be 1 unless the 'recursive' flag is set. The parameter must be initialized beforehand.
This will not resolve any symlinks.
renameTo
This method is identical to moveTo except that if this file or directory is moved to a a different volume, it fails and returns an error (NS_ERROR_FILE_ACCESS_DENIED). This object will still point to the old location after renaming.
setRelativeDescriptor
Initializes the file to the location relative to fromFile using a string returned by getRelativeDescriptor.
the file to which the descriptor is relative
Generated using TypeDoc
The canonical path of the file, which avoids short/long pathname inconsistencies. The nsIFile persistent descriptor is not guaranteed to be canonicalized (it may persist either the long or the short path name). The format of the canonical path will vary with the underlying file system: it will typically be the short pathname on filesystems that support both short and long path forms.