Changeset View
Changeset View
Standalone View
Standalone View
krArc/krarc.cpp
Show First 20 Lines • Show All 341 Lines • ▼ Show 20 Line(s) | 341 | if (permissions != -1) | |||
---|---|---|---|---|---|
342 | initialMode = permissions | S_IWUSR | S_IRUSR; | 342 | initialMode = permissions | S_IWUSR | S_IRUSR; | ||
343 | else | 343 | else | ||
344 | initialMode = 0666; | 344 | initialMode = 0666; | ||
345 | 345 | | |||
346 | QByteArray ba = encodeString(tempFile); | 346 | QByteArray ba = encodeString(tempFile); | ||
347 | ba.prepend(arcTempDirEnc); | 347 | ba.prepend(arcTempDirEnc); | ||
348 | fd = QT_OPEN(ba, O_CREAT | O_TRUNC | O_WRONLY, initialMode); | 348 | fd = QT_OPEN(ba, O_CREAT | O_TRUNC | O_WRONLY, initialMode); | ||
349 | } | 349 | } | ||
350 | | ||||
350 | QByteArray buffer; | 351 | QByteArray buffer; | ||
351 | int readResult; | 352 | int readResult; | ||
353 | bool isIncomplete = false; | ||||
352 | do { | 354 | do { | ||
353 | dataReq(); | 355 | dataReq(); | ||
354 | readResult = readData(buffer); | 356 | readResult = readData(buffer); | ||
355 | ::write(fd, buffer.data(), buffer.size()); | 357 | auto bytesWritten = ::write(fd, buffer.data(), buffer.size()); | ||
358 | if (bytesWritten < buffer.size()) { | ||||
359 | isIncomplete = true; | ||||
360 | break; | ||||
361 | } | ||||
356 | } while (readResult > 0); | 362 | } while (readResult > 0); | ||
357 | ::close(fd); | 363 | ::close(fd); | ||
364 | | ||||
365 | if (isIncomplete) { | ||||
366 | error(ERR_COULD_NOT_WRITE, getPath(url)); | ||||
367 | return; | ||||
368 | } | ||||
369 | | ||||
358 | // pack the file | 370 | // pack the file | ||
359 | KrLinecountingProcess proc; | 371 | KrLinecountingProcess proc; | ||
360 | proc << putCmd << getPath(arcFile->url()) << localeEncodedString(tempFile); | 372 | proc << putCmd << getPath(arcFile->url()) << localeEncodedString(tempFile); | ||
361 | infoMessage(i18n("Packing %1...", url.fileName())); | 373 | infoMessage(i18n("Packing %1...", url.fileName())); | ||
362 | QDir::setCurrent(arcTempDir); | 374 | QDir::setCurrent(arcTempDir); | ||
363 | 375 | | |||
364 | SET_KRCODEC | 376 | SET_KRCODEC | ||
365 | proc.start(); | 377 | proc.start(); | ||
▲ Show 20 Lines • Show All 1553 Lines • Show Last 20 Lines |