[Gambas-user] Move ... Kill function (File & Directory Functions)

Benoît Minisini g4mba5 at gmail.com
Sun Sep 23 17:06:40 CEST 2018


Le 23/09/2018 à 16:01, Hans Lehmann a écrit :
> Hello Fabien,
> 
> thank you very much for the short explanation - fits.
> The function chain 'MOVE OldName KILL NewName' obviously replaces the 
> following source code:
> 
> If Not (Exist(sDestinationPath & sFileName)) Then
>     Try Copy sSourcePath &/ sFileName To sDestinationPath &/ sFileName
> Else
>     Kill sDestinationPath &/ sFileName
>     Try Copy sSourcePath &/ sFileName To sDestinationPath &/ sFileName
>     If Error Then
>        Message.Error("Error! " & Error.Text)
>        Return
>     Endif
> Endif
> 
> Is this correct?
> 
> Yours sincerely
> 
> Hans
> 

Not really: the important word in the command description is "atomic".

Killing and then moving the file does the same thing, but not 
atomically, i.e. there is a time interval during which the target file 
does not exist.

Which is not the case with the MOVE ... KILL ... variant. Linux 
guarantees that the target file always exist (being the older or the 
newer).

This is very important if you need to save a file, being able to 
rollback if there is a problem, and always have a correct version 
existing on the disk.

Regards,

-- 
Benoît Minisini


More information about the User mailing list