Changeset View
Changeset View
Standalone View
Standalone View
smb/kio_smb_dir.cpp
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 160 | { | |||
---|---|---|---|---|---|
171 | { | 171 | { | ||
172 | smbc_close(srcfd); | 172 | smbc_close(srcfd); | ||
173 | } | 173 | } | ||
174 | return; | 174 | return; | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | 177 | | |||
178 | // Perform copy | 178 | // Perform copy | ||
179 | while(1) | 179 | while (true) { | ||
180 | { | | |||
181 | n = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE ); | 180 | n = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE ); | ||
182 | if(n > 0) | 181 | if(n > 0) | ||
183 | { | 182 | { | ||
184 | n = smbc_write(dstfd, buf, n); | 183 | n = smbc_write(dstfd, buf, n); | ||
185 | if(n == -1) | 184 | if(n == -1) | ||
186 | { | 185 | { | ||
187 | qCDebug(KIO_SMB_LOG) << "SMBSlave::copy copy now KIO::ERR_CANNOT_WRITE"; | 186 | qCDebug(KIO_SMB_LOG) << "SMBSlave::copy copy now KIO::ERR_CANNOT_WRITE"; | ||
188 | error( KIO::ERR_CANNOT_WRITE, dst.toDisplayString()); | 187 | error( KIO::ERR_CANNOT_WRITE, dst.toDisplayString()); | ||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 349 | if (srcfd < 0) { | |||
355 | } | 354 | } | ||
356 | return; | 355 | return; | ||
357 | } | 356 | } | ||
358 | 357 | | |||
359 | // Perform the copy | 358 | // Perform the copy | ||
360 | char buf[MAX_XFER_BUF_SIZE]; | 359 | char buf[MAX_XFER_BUF_SIZE]; | ||
361 | bool isErr = false; | 360 | bool isErr = false; | ||
362 | 361 | | |||
363 | while (1) { | 362 | while (true) { | ||
364 | const ssize_t bytesRead = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE); | 363 | const ssize_t bytesRead = smbc_read(srcfd, buf, MAX_XFER_BUF_SIZE); | ||
365 | if (bytesRead <= 0) { | 364 | if (bytesRead <= 0) { | ||
366 | if (bytesRead < 0) { | 365 | if (bytesRead < 0) { | ||
367 | error( KIO::ERR_CANNOT_READ, src.toDisplayString()); | 366 | error( KIO::ERR_CANNOT_READ, src.toDisplayString()); | ||
368 | isErr = true; | 367 | isErr = true; | ||
369 | } | 368 | } | ||
370 | break; | 369 | break; | ||
371 | } | 370 | } | ||
Show All 40 Lines | |||||
412 | } | 411 | } | ||
413 | 412 | | |||
414 | // Restore the mtime on the file. | 413 | // Restore the mtime on the file. | ||
415 | const QString mtimeStr = metaData("modified"); | 414 | const QString mtimeStr = metaData("modified"); | ||
416 | qCDebug(KIO_SMB_LOG) << "modified:" << mtimeStr; | 415 | qCDebug(KIO_SMB_LOG) << "modified:" << mtimeStr; | ||
417 | if (!mtimeStr.isEmpty()) { | 416 | if (!mtimeStr.isEmpty()) { | ||
418 | QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate); | 417 | QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate); | ||
419 | if (dt.isValid()) { | 418 | if (dt.isValid()) { | ||
420 | struct utimbuf utbuf; | 419 | struct utimbuf utbuf{}; | ||
421 | utbuf.actime = QFileInfo(dstFile).lastRead().toSecsSinceEpoch(); // access time, unchanged | 420 | utbuf.actime = QFileInfo(dstFile).lastRead().toSecsSinceEpoch(); // access time, unchanged | ||
422 | utbuf.modtime = dt.toSecsSinceEpoch(); // modification time | 421 | utbuf.modtime = dt.toSecsSinceEpoch(); // modification time | ||
423 | utime(QFile::encodeName(dstFile).constData(), &utbuf); | 422 | utime(QFile::encodeName(dstFile).constData(), &utbuf); | ||
424 | } | 423 | } | ||
425 | } | 424 | } | ||
426 | 425 | | |||
427 | finished(); | 426 | finished(); | ||
428 | } | 427 | } | ||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 430 | { | |||
536 | } | 535 | } | ||
537 | 536 | | |||
538 | bool isErr = false; | 537 | bool isErr = false; | ||
539 | 538 | | |||
540 | if (processed_size == 0 || srcFile.seek(processed_size)) { | 539 | if (processed_size == 0 || srcFile.seek(processed_size)) { | ||
541 | // Perform the copy | 540 | // Perform the copy | ||
542 | char buf[MAX_XFER_BUF_SIZE]; | 541 | char buf[MAX_XFER_BUF_SIZE]; | ||
543 | 542 | | |||
544 | while (1) { | 543 | while (true) { | ||
545 | const ssize_t bytesRead = srcFile.read(buf, MAX_XFER_BUF_SIZE); | 544 | const ssize_t bytesRead = srcFile.read(buf, MAX_XFER_BUF_SIZE); | ||
546 | if (bytesRead <= 0) { | 545 | if (bytesRead <= 0) { | ||
547 | if (bytesRead < 0) { | 546 | if (bytesRead < 0) { | ||
548 | error(KIO::ERR_CANNOT_READ, ksrc.toDisplayString()); | 547 | error(KIO::ERR_CANNOT_READ, ksrc.toDisplayString()); | ||
549 | isErr = true; | 548 | isErr = true; | ||
550 | } | 549 | } | ||
551 | break; | 550 | break; | ||
552 | } | 551 | } | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
596 | } | 595 | } | ||
597 | 596 | | |||
598 | #ifdef HAVE_UTIME_H | 597 | #ifdef HAVE_UTIME_H | ||
599 | // set modification time | 598 | // set modification time | ||
600 | const QString mtimeStr = metaData( "modified" ); | 599 | const QString mtimeStr = metaData( "modified" ); | ||
601 | if (!mtimeStr.isEmpty() ) { | 600 | if (!mtimeStr.isEmpty() ) { | ||
602 | QDateTime dt = QDateTime::fromString( mtimeStr, Qt::ISODate ); | 601 | QDateTime dt = QDateTime::fromString( mtimeStr, Qt::ISODate ); | ||
603 | if ( dt.isValid() ) { | 602 | if ( dt.isValid() ) { | ||
604 | struct utimbuf utbuf; | 603 | struct utimbuf utbuf{}; | ||
605 | utbuf.actime = st.st_atime; // access time, unchanged | 604 | utbuf.actime = st.st_atime; // access time, unchanged | ||
606 | utbuf.modtime = dt.toSecsSinceEpoch(); // modification time | 605 | utbuf.modtime = dt.toSecsSinceEpoch(); // modification time | ||
607 | smbc_utime( dstOrigUrl.toSmbcUrl(), &utbuf ); | 606 | smbc_utime( dstOrigUrl.toSmbcUrl(), &utbuf ); | ||
608 | } | 607 | } | ||
609 | } | 608 | } | ||
610 | #endif | 609 | #endif | ||
611 | 610 | | |||
612 | // We have done our job => finish | 611 | // We have done our job => finish | ||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |