puzzling error of RENAME
I use RENAME to remove a file of "/usr" to the directory "/tmp".
It works well on my pc, but reports error on another. The error info is: Invalid cross-device link Code:
#include <stdio.h> |
The other PC must be using a file system or implementation of rename that doesn't allow symbolic links from one logical device to another.
|
thanks jtshaw,
but on that pc, the command MV does work. is there a portable way to do this? |
Code:
Rename() causes the link named from to be renamed as to. If to exists, |
jtshaw,
thanks. But how can I move file across logical devices? Is there any system call as MV? |
As jtshaw said, mv is using the rename system call only when possible, and if not, is copying the file then remove the source file if the copy succeeds. These operations aren't "atomic" enough to be considered for implementing a system call.
|
thanks jlliagre,
It seems that I have to call MV to move file across logical devices? Is there a better way? Regards |
That's depend on what you mean by better.
calling mv from your program is simpler, implementing your own move code in C can be faster. |
are they on different partitions?
well, if mv is no good why not just write it to the other location and then unlink the original? that's what rename or mv will do. |
All times are GMT -5. The time now is 07:58 AM. |