ArcGIS for Developers

FileInfo QML Type

The FileInfo component provides access to file information. More...

Import Statement: import ArcGIS.AppFramework 1.0
Inherits:

AppFrameworkObject

Inherited By:

ExifInfo

Properties

Methods

Detailed Description

The following code snippet explains the usage of FileInfo component.

App {
    id: app
    width: 800
    height: 532

    Text {
        id: titleText

        anchors {
            left: parent.left
            right: parent.right
            top: parent.top
            topMargin: 100
        }

        Column {
            Text { font.pointSize: 15; text: "File Path : " + fileInfo.filePath }

        }

        color: "#4c4c4c"
        horizontalAlignment: Text.AlignHCenter
    }

    FileInfo {

        id: fileInfo
        filePath:  "~/ArcGIS/AppBuilder/Apps"
    }
}

Enumerations

Permission enumeration

Returns a number that can be interpreted into the permissions available on a file or folder.

This sample returns one of a series of results depending on user permissions.

Item {
        FileInfo {
        id: fileInfo
        filePath: "c:/temp/Bruce.txt"
    }

    Component.onCompleted: {
        var permissionsArray = [];
        var p = fileInfo.permissions.toString();

        console.log(p)

        permissionsArray.push(p);

        if (p & FileInfo.ReadOwner){ permissionsArray.push ("Read Owner");}
        if (p & FileInfo.WriteOwner){ permissionsArray.push ("Write Owner");}
        if (p & FileInfo.ExeOwner){ permissionsArray.push ("Exe Owner");}

        if (p & FileInfo.ReadUser){ permissionsArray.push ("Read User");}
        if (p & FileInfo.WriteUser){ permissionsArray.push ("Write User");}
        if (p & FileInfo.ExeUser){ permissionsArray.push ("Exe User");}

        if (p & FileInfo.ReadGroup){ permissionsArray.push ("Read Group");}
        if (p & FileInfo.WriteGroup){ permissionsArray.push ("Write Group");}
        if (p & FileInfo.ExeGroup){ permissionsArray.push ("Exe Group");}

        if (p & FileInfo.ReadOther){ permissionsArray.push ("Read Other");}
        if (p & FileInfo.WriteOther){ permissionsArray.push ("Write Other");}
        if (p & FileInfo.ExeOther){ permissionsArray.push ("Exe Other");}

        console.log(permissionsArray)
        repeater.model = permissionsArray;
    }

    Column {
        anchors.fill: parent

        Repeater {
            id: repeater

            delegate: Text {
                text: modelData
            }

        }
    }
}
NameValue
FileInfo.ExeOther1
FileInfo.WriteOther2
FileInfo.ReadOther4
FileInfo.ExeGroup16
FileInfo.WriteGroup32
FileInfo.ReadGroup64
FileInfo.ExeUser256
FileInfo.WriteUser512
FileInfo.ReadUser1024
FileInfo.ExeOwner4096
FileInfo.WriteOwner8192
FileInfo.ReadOwner16384

Property Documentation

[read-only] baseName : string

Returns a string value consisting of the base name of the file. The complete base name consists of all characters in the file name up to, but not including, the last '.' character.

For example, if fileInfo's filepath references a folder, the returned value is the folder name e.g. "c:/temp", baseName = temp. If a file is supplied it will return the file name e.g. "c:/temp/bruce.txt" returns 'bruce'.


[read-only] created : time

Returns a time value representing the time the file was created.

For example, "Tue Oct 20 12:12:24 2015 GMT+1100"


[read-only] displayName : string


[read-only] exists : bool

Returns a boolean value. True if the object exists, false if it doesn't.


[read-only] fileName : string

Returns a string value of the file name.

For example,

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"

}

Text {
    text: fileInfo.fileName //returns Bruce.txt
}

filePath : string

Sets the path of a file or a folder.

For example, "c:/temp" or "c:/temp/Bruce.txt"


[read-only] folder : FileFolder

Creates a FileFolder object, and then returns its location.


[read-only] isFile : bool

Returns true if the filePath has been set to a valid file. False will return if a folder was set.

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"

}

Text {
    text: fileInfo.isFile //returns true
}

[read-only] isFolder : bool

Returns true if the filePath has been set to a valid folder. False will return if a file was set.

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"

}

Text {
    text: fileInfo.isFolder //returns false
}

[read-only] isNativePath : bool

Returns true if the filePath has been set to a readable file or folder.


[read-only] isReadable : bool

Returns true if the component determines the file or folder set can be read. False will be returned if it can't.


[read-only] isSymLink : bool

Returns true if the file has been set with a symbolic link, which is a file that exists to link to another file.


[read-only] isWritable : bool

Returns true if the component determines the file or folder set can be edited. False will be returned if it can't.


[read-only] lastModified : time

Returns a date property representing when the file was last modified.

    FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce"
}

Text {
    text: {
        var d = new Date (fileInfo.lastModified)
        return d.getFullYear();
    }
}

[read-only] path : string

Returns the location of the folder path where the file or folder resides.

    FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce"

}

Text {
    text: fileInfo.path // returns "c:/temp"
}

permissions : Permission

Returns the permissions settings of the file.


[read-only] size : int

Returns a number in bytes representing the size of the file, e.g. 210515.

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"
}

Text {
    text: fileInfo.size
}

[read-only] suffix : string

Returns a string value of the last characters of a file's name, after the last period. For example, "txt".

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"
}

Text {
    text: fileInfo.suffix
}

[read-only] symLinkTarget : string

Returns the absolute path to the file or directory a symbolic link points to. If the object is not a symbolic link, returns an empty string.

FileInfo {
    id: fileInfo
    filePath: "C:/Users/gare7065/ArcGIS/AppStudio/Apps/maptourlinked"
}

Text {
    text: fileInfo.symLinkTarget //returns "c:/templateApps/MapTour"
}

[read-only] type : string


url : url

Returns a url of the file or folder address.

FileInfo {
    id: fileInfo
    filePath: "c:/temp/Bruce.txt"
}

Text {
    text: fileInfo.url //returns file:///c:/temp/
}

Method Documentation

var getExtendedProperty(name)

Returns the extended property that is specified by the given name.

The name parameter

The name of the extended property to set. For example, the property ExcludedFromBackup.


bool hasExtendedProperty(name)

Checks if the extended property specified by the given name is present and can be set.

The following code sample checks and then sets the extended property ExcludedFromBackup, a property exclusive to Mac and iOS for declaring files to be left out of backups.

/qml CheckBox { id: excludeFromBackup visible: fileInfo.hasExtendedProperty("ExcludedFromBackup") text: "Exclude from backup"

onClicked: { fileInfo.setExtendedProperty("ExcludedFromBackup", checked); } } /endqml

The name parameter

The name of the extended property to check. For example, the property ExcludedFromBackup.


refresh()

Refreshes the information about the file.

This sample presents a button that refreshes the given file's information.

Item {
    FileInfo {
        id: fileInfo
        filePath: "c:/temp/Bruce.txt"
    }

    Row {
        spacing: 3
        Button {
            text :"refresh"
            onClicked: fileInfo.refresh()
        }
        Text {
            text: fileInfo.lastModified
        }
    }
}

bool setExtendedProperty(name, var value)

The name parameter

The value parameter

See also hasExtendedProperty().


bool setPermissions(permission)

Sets the permissions of the file. This method is informed by the Permission enum.

For example,

fileInfo.setPermissions(FileInfo.ExeOwner)

The permission parameter

The permission to set for the file. For example: Enums.ReadOwner