MuseScore
3.4
Music composition and notation
|
Provides a simple API to perform file reading and writing operations. More...
#include <util.h>
Public Slots | |
void | setSource (const QString &source) |
Signals | |
void | error (const QString &msg) |
Emitted on file operations errors. More... | |
Public Member Functions | |
FileIO (QObject *parent=0) | |
Q_INVOKABLE QString | read () |
Reads file contents and returns a string. More... | |
Q_INVOKABLE bool | exists () |
Returns true if the file exists. More... | |
Q_INVOKABLE bool | write (const QString &data) |
Writes a string to the file. More... | |
Q_INVOKABLE bool | remove () |
Removes the file. More... | |
Q_INVOKABLE QString | homePath () |
Returns user's home directory. More... | |
Q_INVOKABLE QString | tempPath () |
Returns a path suitable for a temporary file. More... | |
Q_INVOKABLE int | modifiedTime () |
Returns the file's last modification time. More... | |
QString | source () |
Properties | |
QString | source |
Path to the file which is operated on. More... | |
Private Attributes | |
QString | mSource |
Provides a simple API to perform file reading and writing operations.
To use this class in a plugin put
to the top part of the .qml plugin file. After that FileIO object can be declared and used in QML code:
|
explicit |
|
signal |
Emitted on file operations errors.
Implement onError() in your FileIO object to handle this signal.
msg | A short textual description of the error occurred. |
bool Ms::PluginAPI::FileIO::exists | ( | ) |
Returns true if the file exists.
|
inline |
Returns user's home directory.
int Ms::PluginAPI::FileIO::modifiedTime | ( | ) |
Returns the file's last modification time.
QString Ms::PluginAPI::FileIO::read | ( | ) |
Reads file contents and returns a string.
In case error occurs, error() signal is emitted and an empty string is returned.
bool Ms::PluginAPI::FileIO::remove | ( | ) |
Removes the file.
|
inlineslot |
|
inline |
|
inline |
Returns a path suitable for a temporary file.
bool Ms::PluginAPI::FileIO::write | ( | const QString & | data | ) |
Writes a string to the file.
true
if an operation finished successfully.
|
private |
|
readwrite |
Path to the file which is operated on.