Interface nsILocalFileMacType

Hierarchy

Properties

bundleContentsLastModifiedTime: int64_t

Last modified time of a bundle's contents (as opposed to its package directory). Our convention is to make the bundle's Info.plist file stand in for the rest of its contents -- since this file contains the bundle's version information and other identifiers. For non-bundles this is the same as lastModifiedTime.

bundleDisplayName: string

bundleDisplayName

returns the display name of the application bundle (usually the human readable name of the application)

bundleIdentifier: string

bundleIdentifier

returns the identifier of the bundle

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.

fileCreator: OSType
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
fileSizeWithResFork: int64_t

fileSizeWithResFork

Returns the combined size of both the data fork and the resource fork (if present) rather than just the size of the data fork as returned by GetFileSize()

fileType: OSType

fileType, creator

File type and creator attributes

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!

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.

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

  • Delete an extended attribute.

    Parameters

    • aAttrName: string

      The extended attribute to delete.

    Returns void

  • Will determine if the inFile equals this.

    Parameters

    • inFile: nsIFile

    Returns boolean

  • getCFURL

    Returns the CFURLRef of the file object. The caller is responsible for calling CFRelease() on it.

    NOTE: Observes the state of the followLinks attribute. If the file object is an alias and followLinks is TRUE, returns the target of the alias. If followLinks is FALSE, returns the unresolved alias file.

    NOTE: Supported only for XP_MACOSX

    Returns

    Returns CFURLRef

  • getFSRef

    Returns the FSRef of the file object.

    NOTE: Observes the state of the followLinks attribute. If the file object is an alias and followLinks is TRUE, returns the target of the alias. If followLinks is FALSE, returns the unresolved alias file.

    NOTE: Supported only for XP_MACOSX

    Returns

    Returns FSRef

  • getFSSpec

    Returns the FSSpec of the file object.

    NOTE: Observes the state of the followLinks attribute. If the file object is an alias and followLinks is TRUE, returns the target of the alias. If followLinks is FALSE, returns the unresolved alias file.

    Returns

    Returns FSSpec

  • 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

  • Return whether or not the file has an extended attribute.

    Returns

    Whether or not the extended attribute is present.

    Parameters

    • aAttrName: string

      The attribute name to check for.

    Returns bool

  • initWithCFURL

    Init this object with a CFURLRef

    NOTE: Supported only for XP_MACOSX NOTE: If the path of the CFURL is /a/b/c, at least a/b must exist beforehand.

    Parameters

    • aCFURL: CFURLRef

      the CoreFoundation URL

    Returns void

  • initWithFSRef

    Init this object with an FSRef

    NOTE: Supported only for XP_MACOSX

    Parameters

    • aFSRef: FSRefPtr

      the native FSRef

    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

  • isPackage

    returns true if a directory is determined to be a package under Mac OS 9/X

    Returns boolean

  • 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

  • launchWithDoc

    Launch the application that this file points to with a document.

    Parameters

    • aDocToLoad: nsIFile

      Must not be NULL. If no document, use nsIFile::launch

    • aLaunchInBackground: boolean

      TRUE if the application should not come to the front.

    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

  • openDocWithApp

    Open the document that this file points to with the given application.

    Parameters

    • aAppToOpenWith: nsIFile

      The application with which to open the document. If NULL, the creator code of the document is used to determine the application.

    • aLaunchInBackground: boolean

      TRUE if the application should not come to the front.

    Returns void

  • 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

  • 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 an extended attribute.

    Parameters

    • aAttrName: string

      The attribute name to set a value for.

    • aAttrValue: invalid

      The value to set for the attribute.

    Returns void

Generated using TypeDoc