revDeleteFolder and Lessons Learned..
dburgun at dsl.pipex.com
Fri Jul 8 08:55:43 EDT 2005
Owwwww, that's just horrible!
I tend to develop code that can do lasting dammage on either a
seperate hard disk or another machine, it's really bad news
developing code on your "everyday" work machine.
Either that or have all my files backed up in a Source Control
Database in server.
I reckon that a change is in order for this. How about a Global
property - "confirmDeletes" (true/false) ? This would be defaulted to
true. Or maybe a "recurseFolders" (true/false) which would control if
folders inside folders should be deleted.
All the Best
>Here's an interesting story:
>Last night I was working on a 'reset prefs' handler which was to
>remove all the files in a folder.
>It looked something like:
> put lMasterFolderPath & "/" & lProjectName into tFolderToDelete
> revDeleteFolder tFolderToDelete
>lMasterFolderPath and lProjectNames are script locals.
>I also have a handler 'checkLocals' which I should've put at the
>top, but I digress.
>In anycase, after applying the script and running, of course the
>script locals are now nulls and the revDeleteFolder contained only a
>single "/", which apparently means: "Delete the entire route hard
>After running it and seeing the processor shoot to 100% and stay
>there, I guessed something was wrong. I tried to quit it, but it's a
>shell script and even the task manager wouldn't allow me to kill it.
>By the time I was able to force shutdown my machine, most the entire
>Windows partition was wasted. Fortunately, my Linux partition was
>still good and I could access my Documents folder and grab most of
>the stuff that mattered, but of course WinXP was completely hosed.
>My lesson learned is NEVER, NEVER, NEVER use revDeleteFolder. I
>rewrote the script to use 'the files' and delete each file
>Hope others can learn from my mistake!
More information about the Use-livecode