Interface nsILocalFileWinType

Hierarchy

Properties

canonicalPath: string

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.

creationTime: number

The 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.

creationTimeOfLink: number
directoryEntries: nsIDirectoryEnumerator

Returns an enumeration of the elements in a directory. Each element in the enumeration is an nsIFile.

Throws

NS_ERROR_FILE_NOT_DIRECTORY if the current nsIFile does not specify a directory.

diskCapacity: int64_t
diskSpaceAvailable: int64_t
displayName: string

The 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.

fileSize: int64_t

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.

fileSizeOfLink: int64_t
lastAccessedTime: number

The last accesss time of the file in milliseconds from midnight, January 1, 1970 GMT, if available.

lastAccessedTimeOfLink: number
lastModifiedTime: number

File Times are to be in milliseconds from midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).

lastModifiedTimeOfLink: number
leafName: string

Accessor to the leaf name of the file itself. For the |nativeLeafName| method, the nativeLeafName must be in the native filesystem charset.

nativeLeafName: string
nativeTarget: string
parent: nsIFile

Parent will be null when this is at the top of the volume.

path: string
permissions: number

Attributes of nsIFile.

permissionsOfLink: number
persistentDescriptor: string

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!

readOnly: bool

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.

target: string

target & 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.

useDOSDevicePathSyntax: boolean

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.)

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • append[Native]

    This function is used for constructing a descendent of the current nsIFile.

    Parameters

    • node: string

      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.

    Returns void

  • appendRelative[Native]Path

    Append a relative path to the current path of the nsIFile object.

    Parameters

    • relativeFilePath: string

      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.

    Returns void

  • clone()

    This function will allocate and initialize a nsIFile object to the exact location of the |this| nsIFile.

    Returns nsIFile

  • Will determine if inFile is a descendant of this file. This routine looks in subdirectories too.

    Parameters

    • inFile: nsIFile

    Returns boolean

  • 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.

    Parameters

    • newParentDir: nsIFile

      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.

    • newName: string

      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.

    Returns void

  • 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.

    Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • 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.

    Parameters

    • type: number

      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).

    • permissions: number

      The unix style octal permissions. This may be ignored on systems that do not need to do permissions.

    • skipAncestors: bool

      Optional; if set to true, we'll skip creating ancestor directories (and return an error instead).

    Returns void

  • 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.

    Parameters

    • type: number

      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).

    • permissions: number

      The unix style octal permissions. This may be ignored on systems that do not need to do permissions.

    Returns void

  • Will determine if the inFile equals this.

    Parameters

    • inFile: nsIFile

    Returns boolean

  • 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!

    Parameters

    • fromFile: nsIFile

      the file from which the descriptor is relative. Throws if fromFile is null.

    Returns string

  • 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.

    Parameters

    • fromFile: nsIFile

      the file from which the path is relative. Throws if fromFile is null.

    Returns string

  • getVersionInfoValue

    Retrieve a metadata field from the file's VERSIONINFO block. Throws NS_ERROR_FAILURE if no value is found, or the value is empty.

    Parameters

    • aField: string

      The field to look up.

    Returns string

  • Return the Windows-specific file attributes of this file.

    Returns number

  • initWithCommandLine

    Initialize this object based on the main app path of a commandline handler.

    Parameters

    • aCommandLine: string

      the commandline to parse an app path out of.

    Returns void

  • initWithFile

    Initialize this object with another file

    Parameters

    • aFile: nsIFile

      the file this becomes equivalent to

    Returns void

  • initWith[Native]Path

    This function will initialize the nsIFile object. Any internal state information will be reset.

    Parameters

    • filePath: string

      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.

    Returns void

  • Not a regular file, not a directory, not a symlink.

    Returns boolean

  • 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.

    Returns void

  • Return the result of PR_LoadLibrary on the file. The caller is responsible for calling PR_UnloadLibrary on the result.

    Returns PRLibraryStar

  • 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.

    Parameters

    • newParentDir: nsIFile

      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.

    • newName: string

      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.

    Returns void

  • 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.

    Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Normalize the pathName (e.g. removing .. and . components on Unix).

    Returns void

  • Return the result of fopen on the file. The caller is responsible for calling fclose on the result. On success, the returned FILE pointer must be non-null.

    Parameters

    • mode: string

    Returns FILE

  • 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.

    Parameters

    • flags: number

      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.

    • mode: number

    Returns PRFileDescStar

  • Identical to nsIFile::openNSPRFileDesc except it also uses the FILE_SHARE_DELETE flag.

    Parameters

    • flags: number
    • mode: number

    Returns PRFileDescStar

  • 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.

    Parameters

    • recursive: boolean
    • removeCount: uint32_t

    Returns void

  • 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.

    Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • Parameters

    • newParentDir: nsIFile
    • newName: string

    Returns void

  • reveal

    Ask 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 and is run async on Windows. This routine must be called on the main.

    Returns void

  • setRelativeDescriptor

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

    Parameters

    • fromFile: nsIFile

      the file to which the descriptor is relative

    • relativeDesc: string

    Returns void

  • setRelativePath

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

    Parameters

    • fromFile: nsIFile

      the file from which the path is relative

    • relativeDesc: string

    Returns void

  • Set or clear the Windows specific file attributes of this file.

    Parameters

    • aSetAttrs: number

      Attribute to set on the file.

    • aClearAttrs: number

      Attributes to clear on the file.

    Returns void

Generated using TypeDoc