Changeset View
Changeset View
Standalone View
Standalone View
src/util/externalcommandhelper.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | |||||
97 | 97 | | |||
98 | /** Reads the given number of bytes from the sourceDevice into the given buffer. | 98 | /** Reads the given number of bytes from the sourceDevice into the given buffer. | ||
99 | @param sourceDevice device or file to read from | 99 | @param sourceDevice device or file to read from | ||
100 | @param buffer buffer to store the bytes read in | 100 | @param buffer buffer to store the bytes read in | ||
101 | @param offset offset where to begin reading | 101 | @param offset offset where to begin reading | ||
102 | @param size the number of bytes to read | 102 | @param size the number of bytes to read | ||
103 | @return true on success | 103 | @return true on success | ||
104 | */ | 104 | */ | ||
105 | bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& buffer, qint64 offset, qint64 size) | 105 | bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size) | ||
106 | { | 106 | { | ||
107 | QFile device(sourceDevice); | 107 | QFile device(sourceDevice); | ||
108 | 108 | | |||
109 | if (!device.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { | 109 | if (!device.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { | ||
110 | qCritical() << xi18n("Could not open device <filename>%1</filename> for reading.", sourceDevice); | 110 | qCritical() << xi18n("Could not open device <filename>%1</filename> for reading.", sourceDevice); | ||
111 | return false; | 111 | return false; | ||
112 | } | 112 | } | ||
113 | 113 | | |||
Show All 13 Lines | |||||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | /** Writes the data from buffer to a given device or file. | 129 | /** Writes the data from buffer to a given device or file. | ||
130 | @param targetDevice device or file to write to | 130 | @param targetDevice device or file to write to | ||
131 | @param buffer the data that we write | 131 | @param buffer the data that we write | ||
132 | @param offset offset where to begin writing | 132 | @param offset offset where to begin writing | ||
133 | @return true on success | 133 | @return true on success | ||
134 | */ | 134 | */ | ||
135 | bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteArray& buffer, qint64 offset) | 135 | bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteArray& buffer, const qint64 offset) | ||
136 | { | 136 | { | ||
137 | QFile device(targetDevice); | 137 | QFile device(targetDevice); | ||
138 | if (!device.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)) { | 138 | if (!device.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)) { | ||
139 | qCritical() << xi18n("Could not open device <filename>%1</filename> for writing.", targetDevice); | 139 | qCritical() << xi18n("Could not open device <filename>%1</filename> for writing.", targetDevice); | ||
140 | return false; | 140 | return false; | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | if (!device.seek(offset)) { | 143 | if (!device.seek(offset)) { | ||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |