Unsolved Qt fails to copy file on ubuntu.
-
@JonB One another possibility for different behaviour: different environments in a terminal and when calling cp with system().
-
@jsulm
Possibly true, but can you name anything in the environment which is going to make a command-line-invokedcp
behave the slightest bit differently wrt syncing to a USB device? Because I can't :) Just in case, perhaps the OP should test running his app from the terminal instead of from Qt Creator if that's what he's currently doing... -
@JonB I can't as well, this is simply something that could make a difference even if I can't say exactly what it could be.
-
Hi,
How are you handling the device ?
Are you mounting manually ?
Is your application responsible for that part too ?
Do you have multiple devices and not writing on the same by accident ? -
@SGaist As I said, I didn't mount or unmount manually.
And I only have one ubuntu system and one USB disk. -
@jsulm @mrjj @JonB @kshegunov @SGaist
Thank you all!
I think maybe I should learn more knowledge about Linux system. -
@Qingshui-Kong
Yes and no! The question you are asking about the behaviour of a mounted USB drive, and seeming to need to either unmount orsync
/fsync()
, is actually a nasty area! I too would not be sure of behaviour, so it's very understandable that you are unsure :) -
@JonB
OK. Thank you! I use sync to solve the problem. -
@Qingshui-Kong
Yes, that seems OK. It forces the OS to flush the pending content to the USB file, without which your problem seems to occur, so it is understandable.Running
sync
on its own asks the OS to flush all file systems, which technically you do not need. If you wish to improve on this, from a terminal runman sync
to read its syntax. There you can see that if you specify the individual USB file path as an argument it will only sync/flush that file system, which is all you need. -
@JonB OK. Thank you very much!