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: | IoDevice |
---|
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: | Error |
---|---|
› 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 |
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¶
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 |
---|---|---|
File.NoError |
0 |
No error occurred or was detected. |
File.InvalidStorageError |
1 |
None or invalid storage set. |
File.StoragePathError |
2 |
Error while creating directories on storage. |
File.OpenError |
3 |
Error while opening file likely due to permission problem. |