Skip to content

Commit 78b31ee

Browse files
committed
feat: functions that interact with optical drive now have return values.
1 parent f4573b2 commit 78b31ee

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

libdisomaster/disomaster.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
if (r <= 0) { \
3434
Xorriso_option_end(x, 1); \
3535
Q_EMIT jobStatusChanged(JobStatus::Failed, -1); \
36-
return; \
36+
return false; \
3737
}
3838

3939
int XorrisoResultHandler(void *handle, char *text);
@@ -277,11 +277,12 @@ void DISOMaster::removeStagingFiles(const QList<QUrl> filelist)
277277
* \param speed desired writing speed in kilobytes per second
278278
* \param closeSession if true, closes the session after files are burned
279279
* \param volId volume name of the disc
280+
* \return true on success, false on failure
280281
*
281282
* closeSession will be ignored if the disc is reusable.
282283
* The staging file list will be cleared afterwards.
283284
*/
284-
void DISOMaster::commit(int speed, bool closeSession, QString volId)
285+
bool DISOMaster::commit(int speed, bool closeSession, QString volId)
285286
{
286287
Q_D(DISOMaster);
287288
Q_EMIT jobStatusChanged(JobStatus::Stalled, 0);
@@ -318,12 +319,15 @@ void DISOMaster::commit(int speed, bool closeSession, QString volId)
318319

319320
XORRISO_OPT(commit, d->xorriso, 0);
320321
JOBFAILED_IF(r, d->xorriso);
322+
323+
return true;
321324
}
322325

323326
/*!
324327
* \brief Erase the disc (if it's not already blank).
328+
* \return true on success, false on failure
325329
*/
326-
void DISOMaster::erase()
330+
bool DISOMaster::erase()
327331
{
328332
Q_D(DISOMaster);
329333
Q_EMIT jobStatusChanged(JobStatus::Running, 0);
@@ -332,17 +336,20 @@ void DISOMaster::erase()
332336
int r;
333337
XORRISO_OPT(blank, d->xorriso, PCHAR("as_needed"), 0);
334338
JOBFAILED_IF(r, d->xorriso);
339+
340+
return true;
335341
}
336342

337343
/*!
338344
* \brief Perform a data integration check for the disc.
339345
* \param qgood if not null, will be set to the portion of sectors that can be read fast.
340346
* \param qslow if not null, will be set to the portion of sectors that can still be read, but slowly.
341347
* \param qbad if not null, will be set to the portion of sectors that are corrupt.
348+
* \return true on success, false on failure (if for some reason the disc could not be checked)
342349
*
343350
* The values returned should add up to 1 (or very close to 1).
344351
*/
345-
void DISOMaster::checkmedia(double *qgood, double *qslow, double *qbad)
352+
bool DISOMaster::checkmedia(double *qgood, double *qslow, double *qbad)
346353
{
347354
Q_D(DISOMaster);
348355
Q_EMIT jobStatusChanged(JobStatus::Running, 0);
@@ -393,6 +400,7 @@ void DISOMaster::checkmedia(double *qgood, double *qslow, double *qbad)
393400

394401
Q_EMIT jobStatusChanged(DISOMaster::JobStatus::Finished, 0);
395402

403+
return true;
396404
}
397405

398406
/*!
@@ -409,8 +417,9 @@ void DISOMaster::dumpISO(const QUrl isopath)
409417
* \brief Burn an image to the disc.
410418
* \param isopath the image file to be burnt.
411419
* \param speed the desired write speed in kilobytes per second.
420+
* \return true on success, false on failure
412421
*/
413-
void DISOMaster::writeISO(const QUrl isopath, int speed)
422+
bool DISOMaster::writeISO(const QUrl isopath, int speed)
414423
{
415424
Q_D(DISOMaster);
416425
Q_EMIT jobStatusChanged(JobStatus::Stalled, 0);
@@ -441,6 +450,8 @@ void DISOMaster::writeISO(const QUrl isopath, int speed)
441450
free(av[i]);
442451
}
443452
delete []av;
453+
454+
return true;
444455
}
445456

446457
void DISOMasterPrivate::getCurrentDeviceProperty()
@@ -527,7 +538,7 @@ void DISOMasterPrivate::messageReceived(int type, char *text)
527538
QString msg(text);
528539
msg = msg.trimmed();
529540

530-
//fprintf(stderr, "msg from xorriso (%s) : %s\n", type ? " info " : "result", msg.toStdString().c_str());
541+
fprintf(stderr, "msg from xorriso (%s) : %s\n", type ? " info " : "result", msg.toStdString().c_str());
531542
xorrisomsg.push_back(msg);
532543

533544
//closing session

libdisomaster/disomaster.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ class DISOMaster : public QObject
9898
void stageFiles(const QHash<QUrl, QUrl> filelist);
9999
const QHash<QUrl, QUrl> &stagingFiles() const;
100100
void removeStagingFiles(const QList<QUrl> filelist);
101-
void commit(int speed = 0, bool closeSession = false, QString volId = "ISOIMAGE");
102-
void erase();
103-
void checkmedia(double *qgood, double *qslow, double *qbad);
101+
bool commit(int speed = 0, bool closeSession = false, QString volId = "ISOIMAGE");
102+
bool erase();
103+
bool checkmedia(double *qgood, double *qslow, double *qbad);
104104

105105
void dumpISO(const QUrl isopath);
106-
void writeISO(const QUrl isopath, int speed = 0);
106+
bool writeISO(const QUrl isopath, int speed = 0);
107107

108108
Q_SIGNALS:
109109
/**

0 commit comments

Comments
 (0)