File
Description
The File object is an IoDevice object allowing to read,:ref:write <method_IoDevice_write> and remove files. In general a file is always stored on a certain storage which also predefines the absolute path to the file. A relative path (i.e. subdirectories) may be included in the file name.
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
error
This property holds the most recently occurred error or File.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
- › Type:
- › Signal:
errorChanged()
- › Attributes:
Readonly
errorString
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
- › Type:
String
- › Signal:
errorStringChanged()
- › Attributes:
Readonly
fileName
This property holds the name of the file. It is always relative to the storage which this file is stored on. The file name has to be set before the file is opened.
- › Type:
String
- › Signal:
fileNameChanged()
- › Attributes:
Writable
storage
This property holds a reference to the storage which the file is stored on. It has to be set before the file is opened.
- › Type:
- › Signal:
storageChanged()
- › Attributes:
Writable
Methods
remove()
This method removes the file specified by fileName and stored on storage.
- › Returns:
Boolean
sync()
This method calls IoDevice.flush() and tells the operating system to write all pending data to its storages. Calling this method might block the program execution for a while depending on the amount of data to be written.
Signals
errorOccurred()
This signal is emitted whenever an error has occurred, regardless of whether the error property has changed or not. In contrast to the change notification signal of the error property this signal is also emitted several times if a certain error occurs several times in succession.
Enumerations
Error
This enumeration describes all errors which can occur in File objects. The most recently occurred error is stored in the error property.
Name |
Value |
Description |
|---|---|---|
|
|
No error occurred or was detected. |
|
|
None or invalid storage set. |
|
|
Error while creating directories on storage. |
|
|
Error while opening file likely due to permission problem. |