Provides methods for accessing standard paths. More...
Import Statement: | import ArcGIS.AppFramework 1.0 |
Inherits: |
Methods
- FileFolder defaultFolder(standardlocation type)
- string displayName(standardlocation type)
- string locate(standardlocation type, string fileName)
- string locate(standardlocation type, string fileName, locateoptions options)
- QStringList locateAll(standardlocation type, string fileName)
- QStringList locateAll(standardlocation type, string fileName, locateoptions options)
- QStringList standardLocations(standardlocation type)
- FileFolder writableFolder(standardlocation type)
- string writableLocation(standardlocation type)
Detailed Description
The StandardPaths component contains functions to query standard locations on the local filesystem. This is often used for aiding common tasks, such as user-specific directories or system-wide configuration directories.
This code sample, primarily demonstrating AudioRecorder in the Multimedia plugin, also includes a typical usage of StandardPaths. The 'Location' button opens a file dialog to the current standard location for music files, allowing you to define a new one.
App { id: app width: 500 height: 100 RowLayout { Layout.fillWidth: true Button { text: "Record" enabled: audioRecorder.available onClicked: audioRecorder.record(); } Button { text: audioRecorder.state == AudioRecorder.PausedState ? "Unpause" : "Pause" enabled: audioRecorder.state == AudioRecorder.RecordingState onClicked: { if (audioRecorder.state == AudioRecorder.PausedState) { audioRecorder.record(); } else { audioRecorder.pause(); } } } Button { text: "Stop" enabled: audioRecorder.state == AudioRecorder.RecordingState || audioRecorder.state == AudioRecorder.PausedState onClicked: audioRecorder.stop(); } Button { text: "Location" enabled: audioRecorder.state == AudioRecorder.StoppedState onClicked: outputDialog.open(); } Button { text: "Play" enabled: audioRecorder.state == AudioRecorder.StoppedState && audioRecorder.actualLocation > "" && audioRecorder.duration > 0 onClicked: { audio.source = audioRecorder.actualLocation; audio.play(); } } } AudioRecorder { id: audioRecorder onStatusChanged: { console.log("audioRecorder status:", status); } onErrorChanged: { console.log("audioRecorder error:", error, "errorString:", errorString); } } FileDialog { id: outputDialog title: qsTr("Output Location") selectExisting: false selectMultiple: false nameFilters: [ "All files (*)" ] folder: AppFramework.resolvedPathUrl(AppFramework.standardPaths.standardLocations(StandardPaths.MusicLocation)[0]) onAccepted: { audioRecorder.outputLocation = fileUrl; } } }
Enumerations
StandardLocation enumeration
This enum describes the locations that are associated with various types of files.
Name | Value |
---|---|
StandardPaths.DesktopLocation | 0 |
StandardPaths.DocumentsLocation | 1 |
StandardPaths.FontsLocation | 2 |
StandardPaths.ApplicationsLocation | 3 |
StandardPaths.MusicLocation | 4 |
StandardPaths.MoviesLocation | 5 |
StandardPaths.PicturesLocation | 6 |
StandardPaths.TempLocation | 7 |
StandardPaths.HomeLocation | 8 |
StandardPaths.DataLocation | 9 |
StandardPaths.AppLocalDataLocation | 9 |
StandardPaths.CacheLocation | 10 |
StandardPaths.GenericDataLocation | 11 |
StandardPaths.RuntimeLocation | 12 |
StandardPaths.ConfigLocation | 13 |
StandardPaths.DownloadLocation | 14 |
StandardPaths.GenericCacheLocation | 15 |
StandardPaths.GenericConfigLocation | 16 |
StandardPaths.AppDataLocation | 17 |
StandardPaths.AppStudioExternalDataLocation | 256 |
StandardPaths.AppStudioHomeLocation | 257 |
StandardPaths.AppStudioPicturesLocation | 258 |
LocateOption enumeration
This enum describes the different flags that can be used for controlling the behavior of locate and locateAll.
Name | Value |
---|---|
StandardPaths.LocateFile | 0 |
StandardPaths.LocateDirectory | 1 |
LocateOptions flags
The LocateOptions flag contains LocateOption enums.
Method Documentation
FileFolder defaultFolder(standardlocation type) |
Returns a single location where files of this type belong, as a FileFolder object. This is ideal for when you want to define a location without requiring user input.
The following code sample demonstrates how to use defaultFolder(), and the result it would produce on a Windows machine.
// Get the default AppDataLocation: var path = AppFramework.standardPaths.defaultFolder(StandardPaths.AppDataLocation).path; // Returns: "C:/Users/USERNAME/AppData/Roaming/Esri/APPNAME"
The type parameter
The type of file to create a subfolder for, i.e. 'pictures' or 'fonts'.
Returns a localized display name for the given location type. Returns an empty string if no relevant location can be found.
The type parameter
The type of file to display the location name for, i.e. 'pictures' or 'fonts'.
Tries to find a file or directory with the given filename, in the standard locations for the defined type.
The type parameter
The type of file to locate the directory for, i.e. 'pictures' or 'fonts'.
The fileName parameter
The name of the file or directory to search for.
Tries to find a file or directory with the given file name, in the standard locations for the defined type.
The type parameter
The type of file to locate the directory for, i.e. 'pictures' or 'fonts'.
The fileName parameter
The name of the file or directory to search for.
The options parameter
0 to return only files, 1 to return only directories.
Tries to find all files or directories with the given filename in the standard locations for the defined file type.
The type parameter
The type of file to locate the directory for, i.e. 'pictures' or 'fonts'.
The fileName parameter
Name of the file or directory to locate.
Attempts to find all files or directories of the given filename, in the standard locations for the defined type. The options flag specifies whether to look for files or directories.
The type parameter
The type of file to locate the directory for, i.e. 'pictures' or 'fonts'.
The fileName parameter
Name of the file or directory to locate.
The options parameter
0 to return only files, 1 to return only directories.
Returns all directories where files of the defined type belong as an array of strings.
The following code sample demonstrates how to use standardLocations(), and the result it would produce on a Windows machine.
// Get an array of AppDataLocation(s): var pathArray = AppFramework.standardPaths.standardLocations(StandardPaths.AppDataLocation); // Returns: // { // "0":"C:/Users/USERNAME/AppData/Roaming/Esri/APPNAME", // "1":"C:/ProgramData/Esri/APPNAME", // "2":"C:/Users/USERNAME/Applications/ArcGIS/AppStudio/bin", // "3":"C:/Users/USERNAME/Applications/ArcGIS/AppStudio/bin/data" // }
The type parameter
The type of file to return the default directory for, i.e. 'pictures' or 'fonts'.
FileFolder writableFolder(standardlocation type) |
If the writable location for the given type is not empty, creates a subfolder within the directory. If the location is empty, this function does nothing.
The type parameter
The type of file to create a subfolder for, i.e. 'pictures' or 'fonts'.
Returns the directory where files of the defined type should be written to. Returns an empty string if the location cannot be determined.
The type parameter
The type of file to return the default directory for, i.e. 'pictures' or 'fonts'.