MoveFileTo across volumes fails

Hi fellow Xojoers,

I’m trying to move a folderitem from one volume to the other and get an os error. Copying works ok. Moving on the same volume is fine. But moving across volumes does not work. Couldn’t find anything anywhere mentioning it’s not supposed to work.

System: Ubuntu 14.04 - x86 - 64 bits
reference to error codes: http://www.thegeekstuff.com/2010/10/linux-error-codes
/media/PJJDATA is a mounted volume pointing to a SD card (permissions are ok, my software reads/writes other stuff in that same folder)
/home/pjjadmin is the regular home folder of the current user (permissions are ok)

Sample:

  'f1 is a valid file
  f1 = new FolderItem("/media/PJJDATA/DownloadCache/PJJRadioPlayer.zip",FolderItem.PathTypeNative) 

  'f2 is a valid destination, /home/pjjadmin is a valid directory but the file itself does not exist
  f2 = new FolderItem("/home/pjjadmin/PJJRadioPlayer.zip",FolderItem.PathTypeNative)

  f1.movefileto f2
  'f1.lasterrorcode is set to 18 : EXDEV Cross-device link
  
  f1.copyfileto f2
  'works ok

Any help/insight?

OS ?
Thats relevant here

As mentioned: Ubuntu 14.04 - x86 - 64 bits

Just to add to the tests I made, opening a terminal on the machine and typing:

mv /media/PJJDATA/DownloadCache/PJJRadioPlayer.zip /home/pjjadmin/PJJRadioPlayer.zip

works fine

Check this http://stackoverflow.com/questions/24209886/invalid-cross-device-link-error-with-boost-filesystem

  f1.MoveFileTo(f2)
  
  If f1.LastErrorCode <> 0 Then
    f1.CopyFileTo(f2)
    f1.Delete()
  End If

That’s the workaround I was about to implement. Either that or use a shell and call “mv” with the shell paths. I understand it’s an OS problem, maybe there could be a note in the Documentation to this effect.

Sorry I missed that this was Ubuntu :stuck_out_tongue:

internally movefileto should, as far as I know, do a copy / delete when it cant do a move directly (usually across volumes)

that its not is curious

what type of file systems are both ?

seems to me like this is a bug

Does Xojo.IO.FolderItem.MoveTo behave the way you expect?

It produce RuntimeException with ErrorNumber = 18.

@Norman Palardy
Filesystem is ext4 both for root (/) and for mounted volume (/media/PJJDATA)

@Paul Lefebvre
Asis beat me to the test :slight_smile:

@Norman Palardy
Before I file a bug report, I’d like to confirm that the expected behaviour is for the framework to detect when a direct move cannot be made and to compensate behind the scenes with a copy/delete combination. If so, I’ll file a bug report.

@Paul Lefebvre
If it’s not, I’ll file a request to add a note/warning in the docs.

Or… a bug report for the new framework and a warning in the doc for the classic ??? :-p

[quote=295039:@Bruno Frechette]@Norman Palardy
Before I file a bug report, I’d like to confirm that the expected behaviour is for the framework to detect when a direct move cannot be made and to compensate behind the scenes with a copy/delete combination. If so, I’ll file a bug report.[/quote]
As far as I can see that should occur