summaryrefslogtreecommitdiff
path: root/library
authorwaspe <waspe>2003-11-04 17:08:12 (UTC)
committer waspe <waspe>2003-11-04 17:08:12 (UTC)
commitdc96afa26288897a9d25ab8c321d8ad350c53f44 (patch) (unidiff)
tree62678d196ae984d246260279c16e49c2923d7a30 /library
parent5865ec3970cead5b2cf3dd255a55cf2e1869e330 (diff)
downloadopie-dc96afa26288897a9d25ab8c321d8ad350c53f44.zip
opie-dc96afa26288897a9d25ab8c321d8ad350c53f44.tar.gz
opie-dc96afa26288897a9d25ab8c321d8ad350c53f44.tar.bz2
resolved merge conflict
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/filemanager.cpp66
1 files changed, 63 insertions, 3 deletions
diff --git a/library/filemanager.cpp b/library/filemanager.cpp
index 91986a0..1c1c998 100644
--- a/library/filemanager.cpp
+++ b/library/filemanager.cpp
@@ -203,13 +203,13 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest )
203 if ( bytesWritten < 0 ) 203 if ( bytesWritten < 0 )
204 ok = FALSE; 204 ok = FALSE;
205 else 205 else
206 bytesRead -= bytesWritten; 206 bytesRead -= bytesWritten;
207 } 207 }
208 } 208 }
209 209
210 if ( ok ) 210 if ( ok )
211 ok = dest.writeLink(); 211 ok = dest.writeLink();
212 212
213 if ( ok ) { 213 if ( ok ) {
214 // okay now rename the file... 214 // okay now rename the file...
215 if ( !renameFile( fn.latin1(), dest.file().latin1() ) ) { 215 if ( !renameFile( fn.latin1(), dest.file().latin1() ) ) {
@@ -222,14 +222,12 @@ bool FileManager::copyFile( const AppLnk &src, const AppLnk &dest )
222 QFile::remove( fn.latin1() ); 222 QFile::remove( fn.latin1() );
223 } 223 }
224 224
225 return ok; 225 return ok;
226} 226}
227 227
228
229
230bool FileManager::copyFile( const QString & src, const QString & dest ) { 228bool FileManager::copyFile( const QString & src, const QString & dest ) {
231 bool success = true; 229 bool success = true;
232 struct stat status; 230 struct stat status;
233 int read_fd=0; 231 int read_fd=0;
234 int write_fd=0; 232 int write_fd=0;
235 struct stat stat_buf; 233 struct stat stat_buf;
@@ -317,12 +315,74 @@ bool FileManager::renameFile( const QString & src, const QString & dest ) {
317 } 315 }
318 } 316 }
319 return false; 317 return false;
320} 318}
321 319
322 320
321=======
322bool FileManager::copyFile( const QString & src, const QString & dest ) {
323 bool success = true;
324 struct stat status;
325 int read_fd=0;
326 int write_fd=0;
327 struct stat stat_buf;
328 off_t offset = 0;
329 QFile srcFile(src);
330 QFile destFile(dest);
331
332 if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
333 return success = false;
334 }
335 read_fd = srcFile.handle();
336 if(read_fd != -1) {
337 fstat (read_fd, &stat_buf);
338 if( !destFile.open( IO_WriteOnly|IO_Raw ) )
339 return success = false;
340 write_fd = destFile.handle();
341 if(write_fd != -1) {
342 int err=0;
343 QString msg;
344 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
345 if( err == -1) {
346 switch(err) {
347 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
348 case EINVAL: msg = "Descriptor is not valid or locked. ";
349 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
350 case EIO: msg = "Unspecified error while reading from in_fd.";
351 };
352 success = false;
353 }
354 } else {
355 qWarning("open write failed %s, %s",src.latin1(), dest.latin1());
356 success = false;
357 }
358 } else {
359 qWarning("open read failed %s, %s",src.latin1(), dest.latin1());
360 success = false;
361 }
362 srcFile.close();
363 destFile.close();
364 // Set file permissions
365 if( stat( (const char *) src, &status ) == 0 ) {
366 chmod( (const char *) dest, status.st_mode );
367 }
368
369 return success;
370}
371
372
373bool FileManager::renameFile( const QString & src, const QString & dest ) {
374 if(copyFile( src, dest )) {
375 if(QFile::remove(src) ) {
376 return true;
377 }
378 }
379 return false;
380}
381
382
323/*! 383/*!
324 Opens the document specified by \a f as a readable QIODevice. 384 Opens the document specified by \a f as a readable QIODevice.
325 The caller must delete the return value. 385 The caller must delete the return value.
326 386
327 Returns 0 if the operation fails. 387 Returns 0 if the operation fails.
328*/ 388*/