-rw-r--r-- | library/filemanager.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp index cc657fa..91986a0 100644 --- a/library/filemanager.cpp +++ b/library/filemanager.cpp | |||
@@ -32,5 +32,14 @@ | |||
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <dirent.h> | 33 | #include <dirent.h> |
34 | #ifdef Q_OS_MACX | ||
35 | // MacOS X does not have sendfile.. :( | ||
36 | // But maybe in the future.. !? | ||
37 | # ifdef SENDFILE | ||
38 | # include <sys/types.h> | ||
39 | # include <sys/socket.h> | ||
40 | # endif | ||
41 | #else | ||
34 | #include <sys/sendfile.h> | 42 | #include <sys/sendfile.h> |
43 | #endif /* Q_OS_MACX */ | ||
35 | #include <fcntl.h> | 44 | #include <fcntl.h> |
36 | 45 | ||
@@ -217,4 +226,6 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest ) | |||
217 | } | 226 | } |
218 | 227 | ||
228 | |||
229 | |||
219 | bool FileManager::copyFile( const QString & src, const QString & dest ) { | 230 | bool FileManager::copyFile( const QString & src, const QString & dest ) { |
220 | bool success = true; | 231 | bool success = true; |
@@ -239,4 +250,33 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) { | |||
239 | int err=0; | 250 | int err=0; |
240 | QString msg; | 251 | QString msg; |
252 | #ifdef Q_OS_MACX | ||
253 | #ifdef SENDMAIL | ||
254 | /* FreeBSD does support a different kind of | ||
255 | * sendfile. (eilers) | ||
256 | * I took this from Very Secure FTPd | ||
257 | * Licence: GPL | ||
258 | * Author: Chris Evans | ||
259 | * sysdeputil.c | ||
260 | */ | ||
261 | /* XXX - start_pos will truncate on 32-bit machines - can we | ||
262 | * say "start from current pos"? | ||
263 | */ | ||
264 | off_t written = 0; | ||
265 | int retval = 0; | ||
266 | retval = sendfile(read_fd, write_fd, offset, stat_buf.st_size, NULL, | ||
267 | &written, 0); | ||
268 | /* Translate to Linux-like retval */ | ||
269 | if (written > 0) | ||
270 | { | ||
271 | err = (int) written; | ||
272 | } | ||
273 | #else /* SENDMAIL */ | ||
274 | err == -1; | ||
275 | msg = "FAILURE: Using unsupported function \"sendfile()\" Need Workaround !!"; | ||
276 | success = false; | ||
277 | # warning "Need workaround for sendfile!!(eilers)" | ||
278 | #endif /* SENDMAIL */ | ||
279 | |||
280 | #else | ||
241 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 281 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
242 | if( err == -1) { | 282 | if( err == -1) { |
@@ -249,4 +289,7 @@ bool FileManager::copyFile( const QString & src, const QString & dest ) { | |||
249 | success = false; | 289 | success = false; |
250 | } | 290 | } |
291 | #endif /* Q_OS_MACX */ | ||
292 | if( !success ) | ||
293 | qWarning( msg ); | ||
251 | } else { | 294 | } else { |
252 | qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); | 295 | qWarning("open write failed %s, %s",src.latin1(), dest.latin1()); |