Cynosure.X International LLC

: :

Add Comment | Related Links | TrackBack
Related Content

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:

DelTree (tmpDir)

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.

Chieh Cheng
Fri, 15 Aug 2008 14:45:26 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Related Links

Add Comment

Spam Control | * indicates required field
Your Name: *
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 10 + 10?
Click button only once, please!


TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

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.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

19 Users Online

Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 1996 - 2021. All Rights Reserved.