author | erik <erik> | 2007-01-10 17:27:56 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-10 17:27:56 (UTC) |
commit | d8e580a239ab84fbe063b2f3779d417598d5ca0a (patch) (side-by-side diff) | |
tree | a8b215c071088f167f011e51027b0a30ef3a5622 | |
parent | e7d3e1d0f3c75979c01ea6373ed3c80d0c986000 (diff) | |
download | opie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.zip opie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.tar.gz opie-d8e580a239ab84fbe063b2f3779d417598d5ca0a.tar.bz2 |
BUG: The case statement was using err to figure out what to say about
why sendfile didn't work. Since err is only the return value of sendfile
this meant that it never reported the right thing because it can only be
-1 at this point. What the author probably wanted to do was look at errno
since that is what the man page says will have the real error info.
FIX: Switch the case statement to use errno.
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 9181810..3986b1f 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -561,49 +561,49 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { struct stat status; QFile srcFile(src); QFile destFile(dest); int err=0; int read_fd=0; int write_fd=0; struct stat stat_buf; off_t offset = 0; if(!srcFile.open( IO_ReadOnly|IO_Raw)) { // owarn << "open failed" << oendl; return success = false; } read_fd = srcFile.handle(); if(read_fd != -1) { fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { // owarn << "destfile open failed" << oendl; return success = false; } write_fd = destFile.handle(); if(write_fd != -1) { err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); if( err == -1) { QString msg; - switch(err) { + switch(errno) { case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; case EINVAL: msg = "Descriptor is not valid or locked. "; case ENOMEM: msg = "Insufficient memory to read from in_fd."; case EIO: msg = "Unspecified error while reading from in_fd."; }; success = false; // owarn << msg << oendl; } } else { success = false; } } else { success = false; } srcFile.close(); destFile.close(); // Set file permissions if( stat( QFile::encodeName(src), &status ) == 0 ) { chmod( QFile::encodeName(dest), status.st_mode ); } return success; } |