Re: ed.ex :: file backup routine

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
K_D_R said...

I believe this routine is fairly "robust", but I tend to get lost in loops. Any suggestions for improvement will certainly be appreciated.

	    if not file_exists(file_name) then  
		-- in "ed.ex" parlance "write" file: 
		save_file(file_name) 
		stop = FALSE 
	    end if  
		 
	    sequence backup_file_name = file_name & "~"  
	    if not file_exists(backup_file_name) then 
		status = eu_filesys:copy_file(file_name, backup_file_name, 0)  
	    end if 

Shouldn't the backup be made before you save the file?

In the first instance, there is no file on the disk to backup, therefore the file is saved before proceeding. Granted, it should be a rare case where a backup would be executed without the file having been previously saved.

But your right, in the subsequent routines I should save the current file after backing up the file on the disk.

As I stated in another post, I am re-writing the routines, taking into account the points you and Pete have made.

Thanks again for your comments.

Regards,

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu