author | llornkcor <llornkcor> | 2004-10-13 21:53:13 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-10-13 21:53:13 (UTC) |
commit | 1f59ac9b59393b46a7ae5d4e1a46e1c1aaf05b23 (patch) (unidiff) | |
tree | 85461425e52ee7e90b40ffeaed7450122a8cb0b0 | |
parent | ff1e5cf77abe865c4ca9beda114577ad4a13e61f (diff) | |
download | opie-1f59ac9b59393b46a7ae5d4e1a46e1c1aaf05b23.zip opie-1f59ac9b59393b46a7ae5d4e1a46e1c1aaf05b23.tar.gz opie-1f59ac9b59393b46a7ae5d4e1a46e1c1aaf05b23.tar.bz2 |
fix move
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f25048a..8b98898 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -237,525 +237,527 @@ void AdvancedFm::filePerms() { | |||
237 | filePath = CurrentDir()->canonicalPath()+"/"; | 237 | filePath = CurrentDir()->canonicalPath()+"/"; |
238 | 238 | ||
239 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 239 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
240 | filePermissions *filePerm; | 240 | filePermissions *filePerm; |
241 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 241 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
242 | QPEApplication::execDialog( filePerm ); | 242 | QPEApplication::execDialog( filePerm ); |
243 | if( filePerm ) | 243 | if( filePerm ) |
244 | delete filePerm; | 244 | delete filePerm; |
245 | } | 245 | } |
246 | populateView(); | 246 | populateView(); |
247 | } | 247 | } |
248 | 248 | ||
249 | void AdvancedFm::doProperties() { | 249 | void AdvancedFm::doProperties() { |
250 | #if defined(QT_QWS_OPIE) | 250 | #if defined(QT_QWS_OPIE) |
251 | 251 | ||
252 | QStringList curFileList = getPath(); | 252 | QStringList curFileList = getPath(); |
253 | 253 | ||
254 | QString filePath; | 254 | QString filePath; |
255 | filePath = CurrentDir()->canonicalPath()+"/"; | 255 | filePath = CurrentDir()->canonicalPath()+"/"; |
256 | 256 | ||
257 | // odebug << "" << curFileList.count() << "" << oendl; | 257 | // odebug << "" << curFileList.count() << "" << oendl; |
258 | 258 | ||
259 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 259 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
260 | // odebug << (filePath+*it) << oendl; | 260 | // odebug << (filePath+*it) << oendl; |
261 | DocLnk lnk( (filePath+*it)); | 261 | DocLnk lnk( (filePath+*it)); |
262 | LnkProperties prop( &lnk ); | 262 | LnkProperties prop( &lnk ); |
263 | QPEApplication::execDialog( &prop ); | 263 | QPEApplication::execDialog( &prop ); |
264 | } | 264 | } |
265 | #endif | 265 | #endif |
266 | 266 | ||
267 | } | 267 | } |
268 | 268 | ||
269 | void AdvancedFm::upDir() { | 269 | void AdvancedFm::upDir() { |
270 | 270 | ||
271 | QDir dir( CurrentDir()->canonicalPath()); | 271 | QDir dir( CurrentDir()->canonicalPath()); |
272 | dir.cdUp(); | 272 | dir.cdUp(); |
273 | changeTo(dir.canonicalPath()); | 273 | changeTo(dir.canonicalPath()); |
274 | } | 274 | } |
275 | 275 | ||
276 | void AdvancedFm::copyTimer() { | 276 | void AdvancedFm::copyTimer() { |
277 | QTimer::singleShot(125,this,SLOT(copy())); | 277 | QTimer::singleShot(125,this,SLOT(copy())); |
278 | } | 278 | } |
279 | 279 | ||
280 | void AdvancedFm::copy() { | 280 | void AdvancedFm::copy() { |
281 | QStringList curFileList = getPath(); | 281 | QStringList curFileList = getPath(); |
282 | 282 | ||
283 | QDir *thisDir = CurrentDir(); | 283 | QDir *thisDir = CurrentDir(); |
284 | QDir *thatDir = OtherDir(); | 284 | QDir *thatDir = OtherDir(); |
285 | 285 | ||
286 | bool doMsg = true; | 286 | bool doMsg = true; |
287 | int count = curFileList.count(); | 287 | int count = curFileList.count(); |
288 | if( count > 0) { | 288 | if( count > 0) { |
289 | if(count > 1 ){ | 289 | if(count > 1 ){ |
290 | QString msg; | 290 | QString msg; |
291 | msg=tr("<p>Really copy %1 files?</p>").arg(count); | 291 | msg=tr("<p>Really copy %1 files?</p>").arg(count); |
292 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 292 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
293 | ,tr("Yes"),tr("No"),0,0,1) ) | 293 | ,tr("Yes"),tr("No"),0,0,1) ) |
294 | { | 294 | { |
295 | case 0: | 295 | case 0: |
296 | doMsg=false; | 296 | doMsg=false; |
297 | break; | 297 | break; |
298 | case 1: | 298 | case 1: |
299 | return; | 299 | return; |
300 | break; | 300 | break; |
301 | default: | 301 | default: |
302 | return; | 302 | return; |
303 | break; | 303 | break; |
304 | }; | 304 | }; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString curFile, item, destFile; | 307 | QString curFile, item, destFile; |
308 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 308 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
309 | item=(*it); | 309 | item=(*it); |
310 | if(item.find("->",0,TRUE)) //symlink | 310 | if(item.find("->",0,TRUE)) //symlink |
311 | item = item.left(item.find("->",0,TRUE)); | 311 | item = item.left(item.find("->",0,TRUE)); |
312 | 312 | ||
313 | curFile = thisDir->canonicalPath()+"/"+ item; | 313 | curFile = thisDir->canonicalPath()+"/"+ item; |
314 | destFile = thatDir->canonicalPath()+"/"+ item; | 314 | destFile = thatDir->canonicalPath()+"/"+ item; |
315 | 315 | ||
316 | // odebug << "Destination file is "+destFile << oendl; | 316 | // odebug << "Destination file is "+destFile << oendl; |
317 | // odebug << "CurrentFile file is " + curFile << oendl; | 317 | // odebug << "CurrentFile file is " + curFile << oendl; |
318 | 318 | ||
319 | QFile f(destFile); | 319 | QFile f(destFile); |
320 | if( f.exists()) { | 320 | if( f.exists()) { |
321 | if(doMsg) { | 321 | if(doMsg) { |
322 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 322 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
323 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 323 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
324 | tr("Yes"),tr("No"),0,0,1)) { | 324 | tr("Yes"),tr("No"),0,0,1)) { |
325 | case 1: | 325 | case 1: |
326 | return; | 326 | return; |
327 | break; | 327 | break; |
328 | default: | 328 | default: |
329 | return; | 329 | return; |
330 | break; | 330 | break; |
331 | }; | 331 | }; |
332 | } | 332 | } |
333 | f.remove(); | 333 | f.remove(); |
334 | } | 334 | } |
335 | 335 | ||
336 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
337 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
338 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 338 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | rePopulate(); | 342 | rePopulate(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void AdvancedFm::copyAsTimer() { | 346 | void AdvancedFm::copyAsTimer() { |
347 | QTimer::singleShot(125,this,SLOT(copyAs())); | 347 | QTimer::singleShot(125,this,SLOT(copyAs())); |
348 | } | 348 | } |
349 | 349 | ||
350 | void AdvancedFm::copyAs() { | 350 | void AdvancedFm::copyAs() { |
351 | 351 | ||
352 | QStringList curFileList = getPath(); | 352 | QStringList curFileList = getPath(); |
353 | QString curFile, item; | 353 | QString curFile, item; |
354 | InputDialog *fileDlg; | 354 | InputDialog *fileDlg; |
355 | 355 | ||
356 | QDir *thisDir = CurrentDir(); | 356 | QDir *thisDir = CurrentDir(); |
357 | QDir *thatDir = OtherDir(); | 357 | QDir *thatDir = OtherDir(); |
358 | 358 | ||
359 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 359 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
360 | QString destFile; | 360 | QString destFile; |
361 | item=(*it); | 361 | item=(*it); |
362 | curFile = thisDir->canonicalPath()+"/"+(*it); | 362 | curFile = thisDir->canonicalPath()+"/"+(*it); |
363 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); | 363 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
364 | 364 | ||
365 | fileDlg->setInputText((const QString &) destFile ); | 365 | fileDlg->setInputText((const QString &) destFile ); |
366 | fileDlg->exec(); | 366 | fileDlg->exec(); |
367 | 367 | ||
368 | if( fileDlg->result() == 1 ) { | 368 | if( fileDlg->result() == 1 ) { |
369 | QString filename = fileDlg->LineEdit1->text(); | 369 | QString filename = fileDlg->LineEdit1->text(); |
370 | destFile = thatDir->canonicalPath()+"/"+filename; | 370 | destFile = thatDir->canonicalPath()+"/"+filename; |
371 | 371 | ||
372 | QFile f( destFile); | 372 | QFile f( destFile); |
373 | if( f.exists()) { | 373 | if( f.exists()) { |
374 | switch (QMessageBox::warning(this,tr("File Exists!"), | 374 | switch (QMessageBox::warning(this,tr("File Exists!"), |
375 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 375 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
376 | tr("Yes"),tr("No"),0,0,1) ) { | 376 | tr("Yes"),tr("No"),0,0,1) ) { |
377 | case 0: | 377 | case 0: |
378 | f.remove(); | 378 | f.remove(); |
379 | break; | 379 | break; |
380 | case 1: | 380 | case 1: |
381 | return; | 381 | return; |
382 | break; | 382 | break; |
383 | default: | 383 | default: |
384 | return; | 384 | return; |
385 | break; | 385 | break; |
386 | }; | 386 | }; |
387 | } | 387 | } |
388 | if( !copyFile( curFile, destFile) ) { | 388 | if( !copyFile( curFile, destFile) ) { |
389 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 389 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
390 | return; | 390 | return; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | delete fileDlg; | 393 | delete fileDlg; |
394 | 394 | ||
395 | } | 395 | } |
396 | rePopulate(); | 396 | rePopulate(); |
397 | // setOtherTabCurrent(); | 397 | // setOtherTabCurrent(); |
398 | qApp->processEvents(); | 398 | qApp->processEvents(); |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | void AdvancedFm::copySameDirTimer() { | 402 | void AdvancedFm::copySameDirTimer() { |
403 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 403 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
404 | } | 404 | } |
405 | 405 | ||
406 | void AdvancedFm::copySameDir() { | 406 | void AdvancedFm::copySameDir() { |
407 | qApp->processEvents(); | 407 | qApp->processEvents(); |
408 | QStringList curFileList = getPath(); | 408 | QStringList curFileList = getPath(); |
409 | QString curFile, item, destFile; | 409 | QString curFile, item, destFile; |
410 | InputDialog *fileDlg; | 410 | InputDialog *fileDlg; |
411 | 411 | ||
412 | QDir *thisDir = CurrentDir(); | 412 | QDir *thisDir = CurrentDir(); |
413 | 413 | ||
414 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 414 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
415 | item=(*it); | 415 | item=(*it); |
416 | curFile = thisDir->canonicalPath()+"/"+ item; | 416 | curFile = thisDir->canonicalPath()+"/"+ item; |
417 | 417 | ||
418 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 418 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
419 | fileDlg->setInputText((const QString &) destFile ); | 419 | fileDlg->setInputText((const QString &) destFile ); |
420 | fileDlg->exec(); | 420 | fileDlg->exec(); |
421 | 421 | ||
422 | if( fileDlg->result() == 1 ) { | 422 | if( fileDlg->result() == 1 ) { |
423 | 423 | ||
424 | QString filename = fileDlg->LineEdit1->text(); | 424 | QString filename = fileDlg->LineEdit1->text(); |
425 | destFile = thisDir->canonicalPath()+"/"+filename; | 425 | destFile = thisDir->canonicalPath()+"/"+filename; |
426 | 426 | ||
427 | QFile f(destFile); | 427 | QFile f(destFile); |
428 | if( f.exists()) { | 428 | if( f.exists()) { |
429 | switch (QMessageBox::warning(this,tr("Delete"), | 429 | switch (QMessageBox::warning(this,tr("Delete"), |
430 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 430 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
431 | tr("Yes"),tr("No"),0,0,1) ) { | 431 | tr("Yes"),tr("No"),0,0,1) ) { |
432 | case 0: | 432 | case 0: |
433 | 433 | ||
434 | f.remove(); | 434 | f.remove(); |
435 | break; | 435 | break; |
436 | case 1: | 436 | case 1: |
437 | return; | 437 | return; |
438 | break; | 438 | break; |
439 | default: | 439 | default: |
440 | return; | 440 | return; |
441 | break; | 441 | break; |
442 | }; | 442 | }; |
443 | } | 443 | } |
444 | if(!copyFile( curFile,destFile) ) { | 444 | if(!copyFile( curFile,destFile) ) { |
445 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 445 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
446 | return; | 446 | return; |
447 | } | 447 | } |
448 | 448 | ||
449 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 449 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
450 | } | 450 | } |
451 | delete fileDlg; | 451 | delete fileDlg; |
452 | } | 452 | } |
453 | rePopulate(); | 453 | rePopulate(); |
454 | } | 454 | } |
455 | 455 | ||
456 | void AdvancedFm::moveTimer() { | 456 | void AdvancedFm::moveTimer() { |
457 | QTimer::singleShot(125,this,SLOT(move())); | 457 | QTimer::singleShot(125,this,SLOT(move())); |
458 | } | 458 | } |
459 | 459 | ||
460 | void AdvancedFm::move() { | 460 | void AdvancedFm::move() { |
461 | 461 | ||
462 | QStringList curFileList = getPath(); | 462 | QStringList curFileList = getPath(); |
463 | if( curFileList.count() > 0) { | 463 | if( curFileList.count() > 0) { |
464 | QString curFile, destFile, item; | 464 | QString curFile, destFile, item; |
465 | 465 | ||
466 | QDir *thisDir = CurrentDir(); | 466 | QDir *thisDir = CurrentDir(); |
467 | QDir *thatDir = OtherDir(); | 467 | QDir *thatDir = OtherDir(); |
468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
469 | item=(*it); | 469 | item=(*it); |
470 | QString destFile = thatDir->canonicalPath(); | 470 | QString destFile = thatDir->canonicalPath(); |
471 | 471 | ||
472 | if(destFile.right(1).find("/",0,TRUE) == -1) | 472 | if(destFile.right(1).find("/",0,TRUE) == -1) |
473 | destFile+="/"; | 473 | destFile+="/"; |
474 | destFile += item; | 474 | destFile += item; |
475 | // odebug << "Destination file is "+destFile << oendl; | 475 | // odebug << "Destination file is "+destFile << oendl; |
476 | 476 | ||
477 | curFile = thisDir->canonicalPath(); | 477 | curFile = thisDir->canonicalPath(); |
478 | if(curFile.right(1).find("/",0,TRUE) == -1) | 478 | if(curFile.right(1).find("/",0,TRUE) == -1) |
479 | curFile +="/"; | 479 | curFile +="/"; |
480 | curFile+= item; | 480 | curFile+= item; |
481 | // odebug << "CurrentFile file is " + curFile << oendl; | 481 | // odebug << "CurrentFile file is " + curFile << oendl; |
482 | 482 | ||
483 | if(QFileInfo(curFile).isDir()) { | 483 | if(QFileInfo(curFile).isDir()) { |
484 | moveDirectory( curFile, destFile ); | 484 | moveDirectory( curFile, destFile ); |
485 | rePopulate(); | 485 | rePopulate(); |
486 | return; | 486 | return; |
487 | } | 487 | } |
488 | QFile f( destFile); | 488 | QFile f( destFile); |
489 | if( f.exists()) { | 489 | if( f.exists()) { |
490 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 490 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
491 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 491 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
492 | tr("Yes"),tr("No"),0,0,1)) { | 492 | tr("Yes"),tr("No"),0,0,1)) { |
493 | case 0: | ||
494 | break; | ||
493 | case 1: | 495 | case 1: |
494 | return; | 496 | return; |
495 | break; | 497 | break; |
496 | default: | 498 | default: |
497 | return; | 499 | return; |
498 | break; | 500 | break; |
499 | }; | 501 | }; |
502 | } | ||
500 | if( !copyFile( curFile, destFile) ) { | 503 | if( !copyFile( curFile, destFile) ) { |
501 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); | 504 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
502 | return; | 505 | return; |
503 | } else | 506 | } else |
504 | QFile::remove(curFile); | 507 | QFile::remove(curFile); |
505 | } | ||
506 | } | 508 | } |
507 | } | 509 | } |
508 | rePopulate(); | 510 | rePopulate(); |
509 | //setOtherTabCurrent(); | 511 | //setOtherTabCurrent(); |
510 | } | 512 | } |
511 | 513 | ||
512 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 514 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
513 | int err = 0; | 515 | int err = 0; |
514 | if( copyDirectory( src, dest ) ) { | 516 | if( copyDirectory( src, dest ) ) { |
515 | QString cmd = "rm -rf " + src; | 517 | QString cmd = "rm -rf " + src; |
516 | err = system((const char*)cmd); | 518 | err = system((const char*)cmd); |
517 | } else | 519 | } else |
518 | err = -1; | 520 | err = -1; |
519 | 521 | ||
520 | if(err!=0) { | 522 | if(err!=0) { |
521 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); | 523 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
522 | return false; | 524 | return false; |
523 | } | 525 | } |
524 | return true; | 526 | return true; |
525 | } | 527 | } |
526 | 528 | ||
527 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 529 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
528 | 530 | ||
529 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 531 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
530 | owarn << cmd << oendl; | 532 | owarn << cmd << oendl; |
531 | int err = system( (const char *) cmd ); | 533 | int err = system( (const char *) cmd ); |
532 | if ( err != 0 ) { | 534 | if ( err != 0 ) { |
533 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); | 535 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
534 | return false; | 536 | return false; |
535 | } | 537 | } |
536 | 538 | ||
537 | return true; | 539 | return true; |
538 | } | 540 | } |
539 | 541 | ||
540 | 542 | ||
541 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 543 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
542 | if(QFileInfo(src).isDir()) { | 544 | if(QFileInfo(src).isDir()) { |
543 | if( copyDirectory( src, dest )) { | 545 | if( copyDirectory( src, dest )) { |
544 | // setOtherTabCurrent(); | 546 | // setOtherTabCurrent(); |
545 | rePopulate(); | 547 | rePopulate(); |
546 | return true; | 548 | return true; |
547 | } | 549 | } |
548 | else | 550 | else |
549 | return false; | 551 | return false; |
550 | } | 552 | } |
551 | 553 | ||
552 | 554 | ||
553 | bool success = true; | 555 | bool success = true; |
554 | struct stat status; | 556 | struct stat status; |
555 | QFile srcFile(src); | 557 | QFile srcFile(src); |
556 | QFile destFile(dest); | 558 | QFile destFile(dest); |
557 | int err=0; | 559 | int err=0; |
558 | int read_fd=0; | 560 | int read_fd=0; |
559 | int write_fd=0; | 561 | int write_fd=0; |
560 | struct stat stat_buf; | 562 | struct stat stat_buf; |
561 | off_t offset = 0; | 563 | off_t offset = 0; |
562 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 564 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
563 | // owarn << "open failed" << oendl; | 565 | // owarn << "open failed" << oendl; |
564 | return success = false; | 566 | return success = false; |
565 | } | 567 | } |
566 | read_fd = srcFile.handle(); | 568 | read_fd = srcFile.handle(); |
567 | if(read_fd != -1) { | 569 | if(read_fd != -1) { |
568 | fstat (read_fd, &stat_buf); | 570 | fstat (read_fd, &stat_buf); |
569 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 571 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
570 | // owarn << "destfile open failed" << oendl; | 572 | // owarn << "destfile open failed" << oendl; |
571 | return success = false; | 573 | return success = false; |
572 | } | 574 | } |
573 | write_fd = destFile.handle(); | 575 | write_fd = destFile.handle(); |
574 | if(write_fd != -1) { | 576 | if(write_fd != -1) { |
575 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 577 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
576 | if( err == -1) { | 578 | if( err == -1) { |
577 | QString msg; | 579 | QString msg; |
578 | switch(err) { | 580 | switch(err) { |
579 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 581 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
580 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 582 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
581 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 583 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
582 | case EIO: msg = "Unspecified error while reading from in_fd."; | 584 | case EIO: msg = "Unspecified error while reading from in_fd."; |
583 | }; | 585 | }; |
584 | success = false; | 586 | success = false; |
585 | // owarn << msg << oendl; | 587 | // owarn << msg << oendl; |
586 | } | 588 | } |
587 | } else { | 589 | } else { |
588 | success = false; | 590 | success = false; |
589 | } | 591 | } |
590 | } else { | 592 | } else { |
591 | success = false; | 593 | success = false; |
592 | } | 594 | } |
593 | srcFile.close(); | 595 | srcFile.close(); |
594 | destFile.close(); | 596 | destFile.close(); |
595 | // Set file permissions | 597 | // Set file permissions |
596 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 598 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
597 | chmod( QFile::encodeName(dest), status.st_mode ); | 599 | chmod( QFile::encodeName(dest), status.st_mode ); |
598 | } | 600 | } |
599 | 601 | ||
600 | return success; | 602 | return success; |
601 | } | 603 | } |
602 | 604 | ||
603 | void AdvancedFm::runCommand() { | 605 | void AdvancedFm::runCommand() { |
604 | if( !CurrentView()->currentItem()) return; | 606 | if( !CurrentView()->currentItem()) return; |
605 | QDir *thisDir = CurrentDir(); | 607 | QDir *thisDir = CurrentDir(); |
606 | 608 | ||
607 | QString curFile; | 609 | QString curFile; |
608 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 610 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
609 | 611 | ||
610 | InputDialog *fileDlg; | 612 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 613 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
612 | fileDlg->setInputText(curFile); | 614 | fileDlg->setInputText(curFile); |
613 | fileDlg->exec(); | 615 | fileDlg->exec(); |
614 | //QString command; | 616 | //QString command; |
615 | 617 | ||
616 | if( fileDlg->result() == 1 ) { | 618 | if( fileDlg->result() == 1 ) { |
617 | // odebug << fileDlg->LineEdit1->text() << oendl; | 619 | // odebug << fileDlg->LineEdit1->text() << oendl; |
618 | QStringList command; | 620 | QStringList command; |
619 | 621 | ||
620 | command << "/bin/sh"; | 622 | command << "/bin/sh"; |
621 | command << "-c"; | 623 | command << "-c"; |
622 | command << fileDlg->LineEdit1->text(); | 624 | command << fileDlg->LineEdit1->text(); |
623 | Output *outDlg; | 625 | Output *outDlg; |
624 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 626 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
625 | QPEApplication::execDialog( outDlg ); | 627 | QPEApplication::execDialog( outDlg ); |
626 | qApp->processEvents(); | 628 | qApp->processEvents(); |
627 | 629 | ||
628 | } | 630 | } |
629 | } | 631 | } |
630 | 632 | ||
631 | void AdvancedFm::runCommandStd() { | 633 | void AdvancedFm::runCommandStd() { |
632 | if( !CurrentView()->currentItem()) return; | 634 | if( !CurrentView()->currentItem()) return; |
633 | QString curFile; | 635 | QString curFile; |
634 | QDir *thisDir = CurrentDir(); | 636 | QDir *thisDir = CurrentDir(); |
635 | QListView *thisView = CurrentView(); | 637 | QListView *thisView = CurrentView(); |
636 | if( thisView->currentItem()) | 638 | if( thisView->currentItem()) |
637 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 639 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
638 | 640 | ||
639 | InputDialog *fileDlg; | 641 | InputDialog *fileDlg; |
640 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 642 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
641 | fileDlg->setInputText(curFile); | 643 | fileDlg->setInputText(curFile); |
642 | fileDlg->exec(); | 644 | fileDlg->exec(); |
643 | 645 | ||
644 | if( fileDlg->result() == 1 ) { | 646 | if( fileDlg->result() == 1 ) { |
645 | qApp->processEvents(); | 647 | qApp->processEvents(); |
646 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 648 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
647 | } | 649 | } |
648 | } | 650 | } |
649 | 651 | ||
650 | void AdvancedFm::fileStatus() { | 652 | void AdvancedFm::fileStatus() { |
651 | if( !CurrentView()->currentItem()) return; | 653 | if( !CurrentView()->currentItem()) return; |
652 | QString curFile; | 654 | QString curFile; |
653 | curFile = CurrentView()->currentItem()->text(0); | 655 | curFile = CurrentView()->currentItem()->text(0); |
654 | 656 | ||
655 | QStringList command; | 657 | QStringList command; |
656 | command << "/bin/sh"; | 658 | command << "/bin/sh"; |
657 | command << "-c"; | 659 | command << "-c"; |
658 | command << "stat -l "+ curFile; | 660 | command << "stat -l "+ curFile; |
659 | 661 | ||
660 | Output *outDlg; | 662 | Output *outDlg; |
661 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 663 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
662 | QPEApplication::execDialog( outDlg ); | 664 | QPEApplication::execDialog( outDlg ); |
663 | qApp->processEvents(); | 665 | qApp->processEvents(); |
664 | } | 666 | } |
665 | 667 | ||
666 | 668 | ||
667 | void AdvancedFm::mkDir() { | 669 | void AdvancedFm::mkDir() { |
668 | makeDir(); | 670 | makeDir(); |
669 | } | 671 | } |
670 | 672 | ||
671 | void AdvancedFm::rn() { | 673 | void AdvancedFm::rn() { |
672 | renameIt(); | 674 | renameIt(); |
673 | } | 675 | } |
674 | 676 | ||
675 | void AdvancedFm::del() { | 677 | void AdvancedFm::del() { |
676 | doDelete(); | 678 | doDelete(); |
677 | } | 679 | } |
678 | 680 | ||
679 | void AdvancedFm::mkSym() { | 681 | void AdvancedFm::mkSym() { |
680 | QString cmd; | 682 | QString cmd; |
681 | QStringList curFileList = getPath(); | 683 | QStringList curFileList = getPath(); |
682 | if( curFileList.count() > 0) { | 684 | if( curFileList.count() > 0) { |
683 | QDir *thisDir = CurrentDir(); | 685 | QDir *thisDir = CurrentDir(); |
684 | QDir * thatDir = OtherDir(); | 686 | QDir * thatDir = OtherDir(); |
685 | 687 | ||
686 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
687 | 689 | ||
688 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 690 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
689 | if(destName.right(1) == "/") { | 691 | if(destName.right(1) == "/") { |
690 | destName = destName.left( destName.length() -1); | 692 | destName = destName.left( destName.length() -1); |
691 | } | 693 | } |
692 | 694 | ||
693 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 695 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
694 | 696 | ||
695 | if( curFile.right(1) == "/") { | 697 | if( curFile.right(1) == "/") { |
696 | curFile = curFile.left( curFile.length() -1); | 698 | curFile = curFile.left( curFile.length() -1); |
697 | } | 699 | } |
698 | 700 | ||
699 | cmd = "ln -s "+curFile+" "+destName; | 701 | cmd = "ln -s "+curFile+" "+destName; |
700 | // odebug << cmd << oendl; | 702 | // odebug << cmd << oendl; |
701 | startProcess( (const QString)cmd ); | 703 | startProcess( (const QString)cmd ); |
702 | } | 704 | } |
703 | rePopulate(); | 705 | rePopulate(); |
704 | setOtherTabCurrent(); | 706 | setOtherTabCurrent(); |
705 | } | 707 | } |
706 | } | 708 | } |
707 | 709 | ||
708 | void AdvancedFm::doBeam() { | 710 | void AdvancedFm::doBeam() { |
709 | Ir ir; | 711 | Ir ir; |
710 | if(!ir.supported()) { | 712 | if(!ir.supported()) { |
711 | } else { | 713 | } else { |
712 | QStringList curFileList = getPath(); | 714 | QStringList curFileList = getPath(); |
713 | if( curFileList.count() > 0) { | 715 | if( curFileList.count() > 0) { |
714 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 716 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
715 | QString curFile = (*it); | 717 | QString curFile = (*it); |
716 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 718 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
717 | if( curFilePath.right(1) == "/") { | 719 | if( curFilePath.right(1) == "/") { |
718 | curFilePath = curFilePath.left( curFilePath.length() -1); | 720 | curFilePath = curFilePath.left( curFilePath.length() -1); |
719 | } | 721 | } |
720 | Ir *file = new Ir(this, "IR"); | 722 | Ir *file = new Ir(this, "IR"); |
721 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 723 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
722 | file->send( curFilePath, curFile ); | 724 | file->send( curFilePath, curFile ); |
723 | } | 725 | } |
724 | } | 726 | } |
725 | } | 727 | } |
726 | } | 728 | } |
727 | 729 | ||
728 | void AdvancedFm::fileBeamFinished( Ir *) { | 730 | void AdvancedFm::fileBeamFinished( Ir *) { |
729 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 731 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
730 | } | 732 | } |
731 | 733 | ||
732 | void AdvancedFm::selectAll() { | 734 | void AdvancedFm::selectAll() { |
733 | QListView *thisView = CurrentView(); | 735 | QListView *thisView = CurrentView(); |
734 | thisView->selectAll(true); | 736 | thisView->selectAll(true); |
735 | thisView->setSelected( thisView->firstChild(),false); | 737 | thisView->setSelected( thisView->firstChild(),false); |
736 | } | 738 | } |
737 | 739 | ||
738 | void AdvancedFm::startProcess(const QString & cmd) { | 740 | void AdvancedFm::startProcess(const QString & cmd) { |
739 | QStringList command; | 741 | QStringList command; |
740 | OProcess *process; | 742 | OProcess *process; |
741 | process = new OProcess(); | 743 | process = new OProcess(); |
742 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 744 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
743 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 745 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
744 | 746 | ||
745 | command << "/bin/sh"; | 747 | command << "/bin/sh"; |
746 | command << "-c"; | 748 | command << "-c"; |
747 | command << cmd.latin1(); | 749 | command << cmd.latin1(); |
748 | *process << command; | 750 | *process << command; |
749 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 751 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
750 | odebug << "could not start process" << oendl; | 752 | odebug << "could not start process" << oendl; |
751 | } | 753 | } |
752 | 754 | ||
753 | void AdvancedFm::processEnded(OProcess *) { | 755 | void AdvancedFm::processEnded(OProcess *) { |
754 | rePopulate(); | 756 | rePopulate(); |
755 | } | 757 | } |
756 | 758 | ||
757 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 759 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
758 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 760 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
759 | 761 | ||
760 | QString lineStr = buffer; | 762 | QString lineStr = buffer; |
761 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 763 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |