[Haskell-cafe] How to move files?

Donn Cave donn at avvanta.com
Thu Apr 15 05:08:20 UTC 2021

>> I don't know how to detect whether two filepaths are in the same 
>> filesystem.

Yes you do!

>> 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)".

And it follows that if you get no error, the two filepaths are in the
same filesystem

>> What's the best way to move the file if possible but copy-and-delete 
>> if necessary?

Catch that error, and copy-and-delete.


More information about the Haskell-Cafe mailing list