The FileInfo component provides access to file information. More...
Import Statement: | import ArcGIS.AppFramework 1.0 |
Inherits: | |
Inherited By: |
Properties
- baseName : string
- created : time
- displayName : string
- exists : bool
- fileName : string
- filePath : string
- folder : FileFolder
- isFile : bool
- isFolder : bool
- isNativePath : bool
- isReadable : bool
- isSymLink : bool
- isWritable : bool
- lastModified : time
- path : string
- permissions : Permission
- size : int
- suffix : string
- symLinkTarget : string
- type : string
- url : url
Methods
- var getExtendedProperty(string name)
- bool hasExtendedProperty(string name)
- refresh()
- bool setExtendedProperty(string name, var value)
- bool setPermissions(permission permission)
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 } } } }
Name | Value |
---|---|
FileInfo.ExeOther | 1 |
FileInfo.WriteOther | 2 |
FileInfo.ReadOther | 4 |
FileInfo.ExeGroup | 16 |
FileInfo.WriteGroup | 32 |
FileInfo.ReadGroup | 64 |
FileInfo.ExeUser | 256 |
FileInfo.WriteUser | 512 |
FileInfo.ReadUser | 1024 |
FileInfo.ExeOwner | 4096 |
FileInfo.WriteOwner | 8192 |
FileInfo.ReadOwner | 16384 |
Property Documentation
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'.
Returns a time value representing the time the file was created.
For example, "Tue Oct 20 12:12:24 2015 GMT+1100"
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 }
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.
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 }
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 }
Returns true if the filePath has been set to a readable file or folder.
Returns true if the component determines the file or folder set can be read. False will be returned if it can't.
Returns true if the file has been set with a symbolic link, which is a file that exists to link to another file.
Returns true if the component determines the file or folder set can be edited. False will be returned if it can't.
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(); } }
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.
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 }
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 }
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" }
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
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.
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.
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 } } }
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