QFile::copy() not working?

Discuss anything related to product development
Post Reply
seasoned_geek
Posts: 61
Joined: Thu Jun 11 2020 12:18 pm

QFile::copy() not working?

Post by seasoned_geek »

I'm on Ubuntu 20.04 LTS and CopperSpice was built from source within the past week or so.

Code: Select all

roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ls -al /home/roland/Diamond_Backups/
total 8
drwxrwxr-x  2 roland roland 4096 Sep  6 16:34 .
drwxr-xr-x 42 roland roland 4096 Sep  6 10:14 ..
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ./cs_hello
Hello World!
copy  /home/roland/Projects/diamond/src/dialog_colors.cpp   to   /home/roland/Diamond_Backups/'!home!roland!Projects!diamond!src!dialog_colors.cpp.b00000'
QFSFileEngine::open() No file name specified
QFSFileEngine::open() No file name specified
failed to copy
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ls -al /home/roland/Diamond_Backups/
total 8
drwxrwxr-x  2 roland roland 4096 Sep  6 16:34 .
drwxr-xr-x 42 roland roland 4096 Sep  6 10:14 ..
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ cp /home/roland/Projects/diamond/src/dialog_colors.cpp /home/roland/Diamond_Backups/'!home!roland!Projects!diamond!src!dialog_colors.cpp.b00000'
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ ls -al /home/roland/Diamond_Backups/
total 40
drwxrwxr-x  2 roland roland  4096 Sep  6 16:36  .
drwxr-xr-x 42 roland roland  4096 Sep  6 10:14  ..
-rw-r--r--  1 roland roland 31443 Sep  6 16:36 '!home!roland!Projects!diamond!src!dialog_colors.cpp.b00000'
roland@roland-amd-desktop:~/Projects/cs_hello_debug$ 

Here's what I put in my little "hello" program to test this out.

Code: Select all

void Task::run()
{
    // Do processing here

    qDebug() << "Hello World!";

    QDir backupDir("/home/roland/Diamond_Backups/");
    QString srcName("/home/roland/Projects/diamond/src/dialog_colors.cpp");
    QString bName("\'!home!roland!Projects!diamond!src!dialog_colors.cpp.b00000\'");
    QString nName = backupDir.absoluteFilePath(bName);
    qDebug() << "copy " << srcName << "  to  " << nName;

    if (!QFile::copy(srcName, nName))
    {
        qDebug() << "failed to copy";
    }
    else
    {
        qDebug() << "copy returned no error";
    }

    emit finished();
}
It's possible I'm just thick as a brick, but the worrisome part was seeing this
QFSFileEngine::open() No file name specified
twice.

I can't just rename() [which does work] because the backup location may not be on the same device as the source file. I really don't want to have one system() call for each OS. According to the documentation this should work.

Tips? Work-arounds? Advice?

Backups are the last major thing on the list for this round of changes to Diamond. Was hoping to put this to bed before end of holiday weekend.

Thanks,

Post Reply