
15 Apr
2021
15 Apr
'21
12:32 a.m.
I'm trying to write to a temp file in /tmp and then move it to another location that may be in /tmp. If I use System.Directory.renameFile and the final location is in another filesystem, I'll get an error "renameFile:renamePath:rename: unsupported operation (Invalid cross-device link)". If I copy to the new location and then remove the temp file, but the new location is also in /tmp, I am doing an unnecessary copy (instead of mv), which is inefficient. I don't know how to detect whether two filepaths are in the same filesystem. What's the best way to move the file if possible but copy-and-delete if necessary? Josh