DelTree () is extremely dangerous
DelTree () is an extremely powerful MortScript function call. Using it, you can wipe out an entire directory structure recursively. But you must be aware of the hidden danger of its secret hydra heads. No, I am not talking about the infamous DelTree ("\") call. Almost any experienced developer knows about the danger of recursive root deletion. Instead, I am talking about its more subtle cousin:
The function call above looks innocent enough. That is until you coupled it with a loose type-checking language like MortScript, which is when the hydra reveals its hidden head. Consider what happens when tmpDir is undefined. It is quite ambiguous what should happen when the parameter is not defined.
I found out the hard way what does happen. Originally, tmpDir was defined. But during code change, tmpDir assignment statement was axed. DelTree (tmpDir) was left in the code. During execution, I found it particular that the script ran so long. Looking at the File Explorer, I realized that it is in the process of deleting the entire storage card recursively. And maybe it will move onto deleting main memory afterward. I will never know, because I immediately rebooted the Windows Mobile device to prevent further destruction. As I took a break from MortScript development while my computer is performing emergency reconstruction of my storage card, I comtemplated about ways to mitigate the risk in the future.
The best mitigation seems To be constant backup of your data. Every time you feel you have made good progress, you should perform a backup. If you have a better way of mitigating this risk, please share your method with us.
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
19 Users Online
Copyright © 1996 - 2021. All Rights Reserved.