Re: file renaming on windows
Does rename returns true or false?
Re: file renaming on windows
Re: file renaming on windows
Are you trying "move" the file across partitions/hard drives or the destination is on the same partition as the source?
Re: file renaming on windows
Same partition / drive. It is actually in the same directory. I want to move the file so I can copy a file to its original name.
Re: file renaming on windows
Maybe you could use QTemporaryFile instead?
Re: file renaming on windows
Thanks for the suggestion, but I'm not sure that will work the way I want it to.
I am basically working on a save mechanism where there is a saved file, and a working file. On a save operation, I want to move the saved file to a temporary name, copy the working file to the saved file name, and then delete the temporary file on success, or rename it back to the saved file if the copy fails. The rename is key, because copying the working file to the save file is the goal, and the rename will free up the save file name.
Re: file renaming on windows
Check if you are not trying to delete an opened file.
Re: file renaming on windows
Doh! Yes, that was the problem. The file was being opened with a QLockedFile somewhere else in the program. Funny how that didn't stop the operation on Linux!
Anyway, thank you both very much for your help. I still have some hair left. :)
Re: file renaming on windows
Quote:
Originally Posted by
jdd81
Funny how that didn't stop the operation on Linux!
The reason is simple. Windows uses mandatory locking while Linux uses advisory locking thus it is possible to ignore the lock on Linux but not on Windows (the latter causes inability to reopen a file after a crash of an application holding a lock to the open file).