Logo Search packages:      
Sourcecode: basket version File versions  Download package

QString Basket::copyFile ( const QString &  srcPath,
const QString &  destFolder,
bool  createIt = false 

DONE: Sometimes we can call two times copyFile() with the same srcPath and destFolder (eg. when exporting basket to HTML with two links to same filename (but not necesary same path, as in "/home/foo.txt" and "/foo.txt") ) The first copy isn't yet started, so the dest file isn't created and this method returns the same filename !!!!!!!!!!!!!!!!!!!!

Definition at line 1935 of file basket.cpp.

      QString fileName = ItemFactory::fileNameForNewFile(KURL(srcPath).fileName(), destFolder);
      QString fullPath = destFolder + fileName;

      if (createIt) {
            // We create the file to be sure another very near call to copyFile() willn't choose the same name:
            QFile file(Item::urlWithoutProtocol(fullPath));
            if ( file.open(IO_WriteOnly) )
            // And then we copy the file AND overwriting the file we juste created:
            new KIO::FileCopyJob(
                  KURL(srcPath), KURL(fullPath), 0666, /*move=*/false,
                  /*overwrite=*/true, /*resume=*/true, /*showProgress=*/true );
      } else
            /*KIO::CopyJob *copyJob = */KIO::copy(KURL(srcPath), KURL(fullPath)); // Do it as before

      return fileName;

Generated by  Doxygen 1.6.0   Back to index